Java Code Examples for org.apache.commons.lang.time.DateUtils#addDays()

The following examples show how to use org.apache.commons.lang.time.DateUtils#addDays() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BaseQueryMetricHandler.java    From datawave with Apache License 2.0 7 votes vote down vote up
public QueryMetricsSummaryHtmlResponse processQueryMetricsHtmlSummary(List<T> queryMetrics) throws IOException {
    
    QueryMetricsSummaryHtmlResponse summary = new QueryMetricsSummaryHtmlResponse();
    Date now = new Date();
    Date hour1 = DateUtils.addHours(now, -1);
    Date hour6 = DateUtils.addHours(now, -6);
    Date hour12 = DateUtils.addHours(now, -12);
    Date day1 = DateUtils.addDays(now, -1);
    Date day7 = DateUtils.addDays(now, -7);
    Date day30 = DateUtils.addDays(now, -30);
    Date day60 = DateUtils.addDays(now, -60);
    Date day90 = DateUtils.addDays(now, -90);
    
    for (T metric : queryMetrics) {
        try {
            binSummary(metric, summary, hour1, hour6, hour12, day1, day7, day30, day60, day90);
        } catch (Exception e1) {
            log.error(e1.getMessage());
        }
    }
    
    return summary;
}
 
Example 2
Source File: QueryParametersImpl.java    From datawave with Apache License 2.0 6 votes vote down vote up
@Override
public void clear() {
    this.query = null;
    this.queryName = null;
    this.persistenceMode = QueryPersistence.TRANSIENT;
    this.pagesize = 10;
    this.pageTimeout = -1;
    this.isMaxResultsOverridden = false;
    this.auths = null;
    this.expirationDate = DateUtils.addDays(new Date(), 1);
    this.trace = false;
    this.beginDate = null;
    this.endDate = null;
    this.visibility = null;
    this.logicName = null;
    this.requestHeaders = null;
}
 
Example 3
Source File: AppDailyDataCenterImpl.java    From cachecloud with Apache License 2.0 6 votes vote down vote up
@Override
public int sendAppDailyEmail() {
    Date endDate = new Date();
    Date startDate = DateUtils.addDays(endDate, -1);
    int successCount = 0;
    List<AppDesc> appDescList = appService.getAllAppDesc();
    for (AppDesc appDesc : appDescList) {
        try {
            boolean result = sendAppDailyEmail(appDesc.getAppId(), startDate, endDate);
            if (result) {
                successCount++;
            }
        } catch (Exception e) {
            logger.error(e.getMessage(), e);
        }
    }
    return successCount;
}
 
Example 4
Source File: HighchartPoint.java    From cachecloud with Apache License 2.0 6 votes vote down vote up
public static HighchartPoint getFromAppCommandStats(AppCommandStats appCommandStats, Date currentDate, int diffDays) throws ParseException {
    Date collectDate = getDateTime(appCommandStats.getCollectTime());
    if (!DateUtils.isSameDay(currentDate, collectDate)) {
        return null;
    }
    
    //显示用的时间
    String date = null;
    try {
        date = DateUtil.formatDate(collectDate, "yyyy-MM-dd HH:mm");
    } catch (Exception e) {
        date = DateUtil.formatDate(collectDate, "yyyy-MM-dd HH");
    }
    // y坐标
    long commandCount = appCommandStats.getCommandCount();
    // x坐标
    //为了显示在一个时间范围内
    if (diffDays > 0) {
        collectDate = DateUtils.addDays(collectDate, diffDays);
    }
    
    return new HighchartPoint(collectDate.getTime(), commandCount, date);
}
 
Example 5
Source File: AppClientDataShowController.java    From cachecloud with Apache License 2.0 5 votes vote down vote up
/**
 * 获取耗时时间区间
 * @throws ParseException 
 */
private TimeBetween fillWithCostDateFormat(HttpServletRequest request, Model model) throws ParseException {
    
    final String costDistriDateFormat = "yyyy-MM-dd";
    String costDistriStartDateParam = request.getParameter("costDistriStartDate");
    String costDistriEndDateParam = request.getParameter("costDistriEndDate");
    Date startDate;
    Date endDate;
    if (StringUtils.isBlank(costDistriStartDateParam) || StringUtils.isBlank(costDistriEndDateParam)) {
        // 如果为空默认取昨天和今天
        SimpleDateFormat sdf = new SimpleDateFormat(costDistriDateFormat);
        startDate = sdf.parse(sdf.format(new Date()));
        endDate = DateUtils.addDays(startDate, 1);
        costDistriStartDateParam = DateUtil.formatDate(startDate, costDistriDateFormat);
        costDistriEndDateParam = DateUtil.formatDate(endDate, costDistriDateFormat);
    } else {
        endDate = DateUtil.parse(costDistriEndDateParam, costDistriDateFormat);
        startDate = DateUtil.parse(costDistriStartDateParam, costDistriDateFormat);
        //限制不能超过1天
        if (endDate.getTime() - startDate.getTime() > TimeUnit.DAYS.toMillis(1)) {
            startDate = DateUtils.addDays(endDate, -1);
        }
    }
    // 前端需要
    model.addAttribute("costDistriStartDate", costDistriStartDateParam);
    model.addAttribute("costDistriEndDate", costDistriEndDateParam);
    // 查询后台需要
    long startTime = NumberUtils.toLong(DateUtil.formatDate(startDate, COLLECT_TIME_FORMAT));
    long endTime = NumberUtils.toLong(DateUtil.formatDate(endDate, COLLECT_TIME_FORMAT));
    return new TimeBetween(startTime, endTime, startDate, endDate);
}
 
Example 6
Source File: InstanceController.java    From cachecloud with Apache License 2.0 5 votes vote down vote up
@RequestMapping("/stat")
public ModelAndView stat(HttpServletRequest request, HttpServletResponse response, Model model, Integer admin, Long instanceId) {

    String startDateParam = request.getParameter("startDate");
    String endDateParam = request.getParameter("endDate");

    if (StringUtils.isBlank(startDateParam) || StringUtils.isBlank(endDateParam)) {
        Date endDate = new Date();
        Date startDate = DateUtils.addDays(endDate, -1);
        startDateParam = DateUtil.formatDate(startDate, "yyyyMMdd");
        endDateParam = DateUtil.formatDate(endDate, "yyyyMMdd");
    }
    model.addAttribute("startDate", startDateParam);
    model.addAttribute("endDate", endDateParam);

    if (instanceId != null && instanceId > 0) {
        model.addAttribute("instanceId", instanceId);
        InstanceInfo instanceInfo = instanceStatsCenter.getInstanceInfo(instanceId);
        model.addAttribute("instanceInfo", instanceInfo);
        model.addAttribute("appId", instanceInfo.getAppId());
        model.addAttribute("appDetail", appStatsCenter.getAppDetail(instanceInfo.getAppId()));
        InstanceStats instanceStats = instanceStatsCenter.getInstanceStats(instanceId);
        model.addAttribute("instanceStats", instanceStats);
        List<AppCommandStats> topLimitAppCommandStatsList = appStatsCenter.getTopLimitAppCommandStatsList(instanceInfo.getAppId(), Long.parseLong(startDateParam) * 10000, Long.parseLong(endDateParam) * 10000, 5);
        model.addAttribute("appCommandStats", topLimitAppCommandStatsList);
    }
    return new ModelAndView("instance/instanceStat");
}
 
Example 7
Source File: ContractsGrantsReportHelperServiceImpl.java    From kfs with GNU Affero General Public License v3.0 5 votes vote down vote up
/**
 * @see org.kuali.kfs.module.ar.report.service.ContractsGrantsReportHelperService#appendEndTimeToDate(java.lang.String)
 */
@Override
public String correctEndDateForTime(String dateString) {
    try {
        final Date dateDate = DateUtils.addDays(dateTimeService.convertToDate(dateString), 1);
        final String newDateString = dateTimeService.toString(dateDate, KFSConstants.MONTH_DAY_YEAR_DATE_FORMAT);
        return newDateString;
    }
    catch (ParseException ex) {
        LOG.warn("invalid date format for errorDate: " + dateString);
    }
    return KFSConstants.EMPTY_STRING;
}
 
Example 8
Source File: AppManageController.java    From cachecloud with Apache License 2.0 5 votes vote down vote up
@RequestMapping("/appDaily")
public ModelAndView appDaily(HttpServletRequest request, HttpServletResponse response, Model model) throws ParseException {
 AppUser userInfo = getUserInfo(request);
    logger.warn("user {} want to send appdaily", userInfo.getName());
    if (ConstUtils.SUPER_MANAGER.contains(userInfo.getName())) {
        Date startDate;
        Date endDate;
        String startDateParam = request.getParameter("startDate");
        String endDateParam = request.getParameter("endDate");
        if (StringUtils.isBlank(startDateParam) || StringUtils.isBlank(endDateParam)) {
            endDate = new Date();
            startDate = DateUtils.addDays(endDate, -1);
        } else {
            startDate = DateUtil.parseYYYY_MM_dd(startDateParam);
            endDate = DateUtil.parseYYYY_MM_dd(endDateParam);
        }
        long appId = NumberUtils.toLong(request.getParameter("appId"));
        if (appId > 0) {
            appDailyDataCenter.sendAppDailyEmail(appId, startDate, endDate);
        } else {
            appDailyDataCenter.sendAppDailyEmail();
        }
        model.addAttribute("msg", "success!");
    } else {
        model.addAttribute("msg", "no power!");
    }
    return new ModelAndView("");
}
 
Example 9
Source File: AppController.java    From cachecloud with Apache License 2.0 5 votes vote down vote up
/**
 * 多时间组装
 * @param appStats
 * @param statName
 * @param startDate
 * @param endDate
 * @return
 */
private String assembleMutilDateAppStatsJsonMinute(List<AppStats> appStats, String statName, Date startDate, Date endDate) {
    if (appStats == null || appStats.isEmpty()) {
        return "[]";
    }
    Map<String, List<HighchartPoint>> map = new HashMap<String, List<HighchartPoint>>();
    Date currentDate = DateUtils.addDays(endDate, -1);
    int diffDays = 0;
    while (currentDate.getTime() >= startDate.getTime()) {
        List<HighchartPoint> list = new ArrayList<HighchartPoint>();
        for (AppStats stat : appStats) {
            try {
                HighchartPoint highchartPoint = HighchartPoint.getFromAppStats(stat, statName, currentDate, diffDays);
                if (highchartPoint == null) {
                    continue;
                }
                list.add(highchartPoint);
            } catch (ParseException e) {
                logger.info(e.getMessage(), e);
            }
        }
        String formatDate = DateUtil.formatDate(currentDate, "yyyy-MM-dd");
        map.put(formatDate, list);
        currentDate = DateUtils.addDays(currentDate, -1);
        diffDays++;
    }
    net.sf.json.JSONObject jsonObject = net.sf.json.JSONObject.fromObject(map);
    return jsonObject.toString();
}
 
Example 10
Source File: AppController.java    From cachecloud with Apache License 2.0 5 votes vote down vote up
private String assembleMutilDateAppCommandJsonMinute(List<AppCommandStats> appCommandStats, Date startDate, Date endDate) {
    if (appCommandStats == null || appCommandStats.isEmpty()) {
        return "[]";
    }
    Map<String, List<HighchartPoint>> map = new HashMap<String, List<HighchartPoint>>();
    Date currentDate = DateUtils.addDays(endDate, -1);
    int diffDays = 0;
    while (currentDate.getTime() >= startDate.getTime()) {
        List<HighchartPoint> list = new ArrayList<HighchartPoint>();
        for (AppCommandStats stat : appCommandStats) {
            try {
                HighchartPoint highchartPoint = HighchartPoint.getFromAppCommandStats(stat, currentDate, diffDays);
                if (highchartPoint == null) {
                    continue;
                }
                list.add(highchartPoint);
            } catch (ParseException e) {
                logger.info(e.getMessage(), e);
            }
        }
        String formatDate = DateUtil.formatDate(currentDate, "yyyy-MM-dd");
        map.put(formatDate, list);
        currentDate = DateUtils.addDays(currentDate, -1);
        diffDays++;
    }
    net.sf.json.JSONObject jsonObject = net.sf.json.JSONObject.fromObject(map);
    return jsonObject.toString();
}
 
Example 11
Source File: HighchartPoint.java    From cachecloud with Apache License 2.0 5 votes vote down vote up
public static HighchartPoint getFromAppStats(AppStats appStat, String statName, Date currentDate, int diffDays) throws ParseException {
    Date collectDate = getDateTime(appStat.getCollectTime());
    if (!DateUtils.isSameDay(currentDate, collectDate)) {
        return null;
    }
    //显示用的时间
    String date = null;
    try {
        date = DateUtil.formatDate(collectDate, "yyyy-MM-dd HH:mm");
    } catch (Exception e) {
        date = DateUtil.formatDate(collectDate, "yyyy-MM-dd HH");
    }
    // y坐标
    long count = 0;
    if ("hits".equals(statName)) {
        count = appStat.getHits();
    } else if ("misses".equals(statName)) {
        count = appStat.getMisses();
    } else if ("usedMemory".equals(statName)) {
        count = appStat.getUsedMemory() / 1024 / 1024;
    } else if ("netInput".equals(statName)) {
        count = appStat.getNetInputByte();
    } else if ("netOutput".equals(statName)) {
        count = appStat.getNetOutputByte();
    } else if ("connectedClient".equals(statName)) {
        count = appStat.getConnectedClients();
    } else if ("objectSize".equals(statName)) {
        count = appStat.getObjectSize();
    } else if ("hitPercent".equals(statName)) {
        count = appStat.getHitPercent();
    }
    //为了显示在一个时间范围内
    if (diffDays > 0) {
        collectDate = DateUtils.addDays(collectDate, diffDays);
    }
    
    return new HighchartPoint(collectDate.getTime(), count, date);
}
 
Example 12
Source File: HibernateProgramInstanceStore.java    From dhis2-core with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public List<ProgramInstance> getWithScheduledNotifications( ProgramNotificationTemplate template, Date notificationDate )
{
    if ( notificationDate == null || !SCHEDULED_PROGRAM_INSTANCE_TRIGGERS.contains( template.getNotificationTrigger() ) )
    {
        return Lists.newArrayList();
    }

    String dateProperty = toDateProperty( template.getNotificationTrigger() );

    if ( dateProperty == null )
    {
        return Lists.newArrayList();
    }

    Date targetDate = DateUtils.addDays( notificationDate, template.getRelativeScheduledDays() * -1 );

    String hql =
        "select distinct pi from ProgramInstance as pi " +
            "inner join pi.program as p " +
            "where :notificationTemplate in elements(p.notificationTemplates) " +
            "and pi." + dateProperty + " is not null " +
            "and pi.status = :activeEnrollmentStatus " +
            "and cast(:targetDate as date) = pi." + dateProperty;

    return getQuery( hql )
        .setParameter( "notificationTemplate", template )
        .setParameter( "activeEnrollmentStatus", ProgramStatus.ACTIVE )
        .setParameter( "targetDate", targetDate ).list();
}
 
Example 13
Source File: UpcomingMilestoneNotificationServiceImpl.java    From kfs with GNU Affero General Public License v3.0 5 votes vote down vote up
/**
 * @see org.kuali.kfs.module.ar.batch.service.UpcomingMilestoneNotificationService#sendNotificationsForMilestones()
 */
@Override
@Transactional
public void sendNotificationsForMilestones() {
    int limitDays = new Integer(parameterService.getParameterValueAsString(UpcomingMilestoneNotificationStep.class, ArConstants.CHECK_LIMIT_DAYS));
    final Date expectedCompletionLimitDate = DateUtils.addDays(dateTimeService.getCurrentDate(), limitDays);

    List<Milestone> milestones = (List<Milestone>) milestoneDao.getMilestonesForNotification(expectedCompletionLimitDate);
    if (CollectionUtils.isNotEmpty(milestones)) {
        sendAdviceNotifications(milestones, milestones.get(0).getAward());
    }
}
 
Example 14
Source File: HibernateProgramStageInstanceStore.java    From dhis2-core with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public List<ProgramStageInstance> getWithScheduledNotifications( ProgramNotificationTemplate template, Date notificationDate )
{
    if ( notificationDate == null || !SCHEDULED_PROGRAM_STAGE_INSTANCE_TRIGGERS.contains( template.getNotificationTrigger() ) )
    {
        return Lists.newArrayList();
    }

    if ( template.getRelativeScheduledDays() == null )
    {
        return Lists.newArrayList();
    }

    Date targetDate = DateUtils.addDays( notificationDate, template.getRelativeScheduledDays() * -1 );

    String hql =
        "select distinct psi from ProgramStageInstance as psi " +
            "inner join psi.programStage as ps " +
            "where :notificationTemplate in elements(ps.notificationTemplates) " +
            "and psi.dueDate is not null " +
            "and psi.executionDate is null " +
            "and psi.status != :skippedEventStatus " +
            "and cast(:targetDate as date) = psi.dueDate " +
            "and psi.deleted is false";

    return getQuery( hql )
        .setParameter( "notificationTemplate", template )
        .setParameter( "skippedEventStatus", EventStatus.SKIPPED )
        .setParameter( "targetDate", targetDate ).list();
}
 
Example 15
Source File: AppClientDataShowController.java    From cachecloud with Apache License 2.0 5 votes vote down vote up
/**
 * 值分布日期格式
 */
private TimeBetween fillWithValueDistriTime(HttpServletRequest request, Model model) throws ParseException {
    final String valueDistriDateFormat = "yyyy-MM-dd";
    String valueDistriStartDateParam = request.getParameter("valueDistriStartDate");
    String valueDistriEndDateParam = request.getParameter("valueDistriEndDate");
    Date startDate;
    Date endDate;
    if (StringUtils.isBlank(valueDistriStartDateParam) || StringUtils.isBlank(valueDistriEndDateParam)) {
        // 如果为空默认取昨天和今天
        SimpleDateFormat sdf = new SimpleDateFormat(valueDistriDateFormat);
        startDate = sdf.parse(sdf.format(new Date()));
        endDate = DateUtils.addDays(startDate, 1);
        valueDistriStartDateParam = DateUtil.formatDate(startDate, valueDistriDateFormat);
        valueDistriEndDateParam = DateUtil.formatDate(endDate, valueDistriDateFormat);
    } else {
        endDate = DateUtil.parse(valueDistriEndDateParam, valueDistriDateFormat);
        startDate = DateUtil.parse(valueDistriStartDateParam, valueDistriDateFormat);
        //限制不能超过1天
        if (endDate.getTime() - startDate.getTime() > TimeUnit.DAYS.toMillis(1)) {
            startDate = DateUtils.addDays(endDate, -1);
        }
    }
    // 前端需要
    model.addAttribute("valueDistriStartDate", valueDistriStartDateParam);
    model.addAttribute("valueDistriEndDate", valueDistriEndDateParam);
    // 查询后台需要
    long startTime = NumberUtils.toLong(DateUtil.formatDate(startDate, COLLECT_TIME_FORMAT));
    long endTime = NumberUtils.toLong(DateUtil.formatDate(endDate, COLLECT_TIME_FORMAT));
    return new TimeBetween(startTime, endTime, startDate, endDate);
}
 
Example 16
Source File: CustomerInvoiceDocumentServiceImpl.java    From kfs with GNU Affero General Public License v3.0 5 votes vote down vote up
/**
 * get the date before the given amount of days
 */
protected Date getPastDate(Integer amount){
    Integer pastDateAmount = -1 * amount;

    java.util.Date today = this.getDateTimeService().getCurrentDate();
    java.util.Date pastDate = DateUtils.addDays(today, pastDateAmount);

    return KfsDateUtils.convertToSqlDate(pastDate);
}
 
Example 17
Source File: MysqlMethodInvocationHandler.java    From Mycat2 with GNU General Public License v3.0 4 votes vote down vote up
private SQLExpr invokeAddDate(SQLMethodInvokeExpr expr, boolean negative) throws SQLNonTransientException {
    List<SQLExpr> parameters = expr.getParameters();
    if (parameters.size() != 2) {
        throwSyntaxError(expr);
    }
    SQLExpr p1 = parameters.get(0);
    SQLExpr p2 = parameters.get(1);
    if (p1 instanceof SQLMethodInvokeExpr) {
        p1 = doInvoke((SQLMethodInvokeExpr) p1);
    }
    if (p1 instanceof SQLCharExpr) {
        String time = ((SQLCharExpr) p1).getText();
        Integer delta = null;
        String unit = null;
        if (p2 instanceof SQLIntegerExpr) {
            delta = (Integer) ((SQLIntegerExpr) p2).getNumber();
            unit = "DAY";
        } else if (p2 instanceof MySqlIntervalExpr) {
            SQLIntegerExpr value = (SQLIntegerExpr) ((MySqlIntervalExpr) p2).getValue();
            delta = (Integer) value.getNumber();
            unit = ((MySqlIntervalExpr) p2).getUnit().name();
        } else {
            throwSyntaxError(p2);
        }
        try {
            Date date = DateUtils.parseDate(time, SUPPORT_PATTERNS);
            Date result;
            delta = negative ? -delta : delta;
            if ("MONTH".equals(unit)) {
                result = DateUtils.addMonths(date, delta);
            } else if ("DAY".equals(unit)) {
                result = DateUtils.addDays(date, delta);
            } else if ("HOUR".equals(unit)) {
                result = DateUtils.addHours(date, delta);
            } else if ("MINUTE".equals(unit)) {
                result = DateUtils.addMinutes(date, delta);
            } else if ("SECOND".equals(unit)) {
                result = DateUtils.addSeconds(date, delta);
            } else {
                return null;
            }
            String ret = DateFormatUtils.format(result, "yyyy-MM-dd HH:mm:ss");
            return new SQLIdentifierExpr(ret);
        } catch (ParseException e) {
            LOGGER.error("",e);
        }
    }
    return null;
}
 
Example 18
Source File: DataValueSetServiceTest.java    From dhis2-core with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
private Period createMonthlyPeriod( Date monthStart )
{
    Date monthEnd = DateUtils.addDays( DateUtils.addMonths( monthStart, 1 ), -1 );

    return createPeriod( PeriodType.getByNameIgnoreCase( MonthlyPeriodType.NAME ), monthStart, monthEnd );
}
 
Example 19
Source File: CustomerInvoiceDocumentBatchStep.java    From kfs with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
    public boolean execute(String jobName, Date jobRunDate) throws InterruptedException {


        Parameter runIndicatorParameter = getParameterService().getParameter(RUN_INDICATOR_PARAMETER_NAMESPACE_CODE, RUN_INDICATOR_PARAMETER_NAMESPACE_STEP, Job.STEP_RUN_PARM_NM);
        if (runIndicatorParameter == null || StringUtils.equals("Y", runIndicatorParameter.getValue())) {

            GlobalVariables.clear();
            GlobalVariables.setUserSession(new UserSession(INITIATOR_PRINCIPAL_NAME));

            Date billingDate = getDateTimeService().getCurrentDate();
            List<String> customernames;

            if ((jobName.length() <=8 ) && (jobName.length() >= 4)) {
                customernames = Arrays.asList(jobName);
            } else {
                customernames = Arrays.asList("ABB2", "3MC17500","ACE21725","ANT7297","CAR23612", "CON19567", "DEL14448", "EAT17609", "GAP17272");
            }

            // create non-random data
            if (customernames.size() > 1) {
                for (int i = 0; i < NUMBER_OF_INVOICES_TO_CREATE; i++) {

                    billingDate = DateUtils.addDays(billingDate, -30);

                    createCustomerInvoiceDocumentForFunctionalTesting("HIL22195", billingDate, 1, new KualiDecimal(10), new BigDecimal(1), "2336320", "BL", "BUSCF");  // $10 entries
                    createCustomerInvoiceDocumentForFunctionalTesting("IBM2655", billingDate, 2, new KualiDecimal(10), new BigDecimal(1), "2336320", "BL", "IBCE");  // $20 entries
                    createCustomerInvoiceDocumentForFunctionalTesting("JAS19572", billingDate, 3, new KualiDecimal(10), new BigDecimal(1), "2336320", "BL", "WRB");  // $30 entries

                    Thread.sleep(500);
                }
            }

            // easy dynamic data creation
            if (customernames.size() == 1) {
                billingDate = jobRunDate;
                createCustomerInvoiceDocumentForFunctionalTesting(customernames.get(0), billingDate, 1, new KualiDecimal(10), new BigDecimal(1), "1111111", "BA", "MATT");  // $10 entries
                Thread.sleep(500);
            }

            // create lockboxes for the non-random invoices
            Long seqNbr = findAvailableLockboxBaseSeqNbr();
            int scenarioNbr =1;
            for (String createdInvoice : createdInvoices){
                createLockboxesForFunctionalTesting(createdInvoice, seqNbr, scenarioNbr);
                Thread.sleep(500);
                seqNbr++;
                if (scenarioNbr<=6) {
                    scenarioNbr++;
                }
                else {
                    scenarioNbr = 1;
                }
            }

            // create random data
//            if (customernames.size() > 1) {
//                for (String customername : customernames) {
//
//                    billingDate = getDateTimeService().getCurrentDate();
//
//                    for( int i = 0; i < NUMBER_OF_INVOICES_TO_CREATE; i++ ){
//
//                        billingDate = KfsDateUtils.addDays(billingDate, -30);
//
//                        createCustomerInvoiceDocumentForFunctionalTesting(customername,billingDate, 0, null, null, "1031400", "BL");
//                        Thread.sleep(500);
//
//                    }
//                }
//            }



            // save runParameter as "N" so that the job won't run until DB has been cleared
            setInitiatedParameter();
        }
        return true;
    }
 
Example 20
Source File: DefaultQueryPlanner.java    From datawave with Apache License 2.0 2 votes vote down vote up
/**
 * Given a date, truncate it to year, month, date and increment the day by one to determine the following day.
 *
 * @param endDate
 * @return
 */
public static Date getEndDateForIndexLookup(Date endDate) {
    Date newDate = DateUtils.truncate(endDate, Calendar.DATE);
    return DateUtils.addDays(newDate, 1);
}