本文整理匯總了Java中org.apache.commons.lang.time.DateUtils.addDays方法的典型用法代碼示例。如果您正苦於以下問題:Java DateUtils.addDays方法的具體用法?Java DateUtils.addDays怎麽用?Java DateUtils.addDays使用的例子?那麽恭喜您, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.commons.lang.time.DateUtils的用法示例。
在下文中一共展示了DateUtils.addDays方法的26個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於我們的係統推薦出更棒的Java代碼示例。
示例1: getTimeBetween
點讚 4
import org.apache.commons.lang.time.DateUtils; //導入方法依賴的package包/類
protected TimeBetween getTimeBetween(HttpServletRequest request, Model model, String startDateAtr,
String endDateAtr) throws ParseException {
String startDateParam = request.getParameter(startDateAtr);
String endDateParam = request.getParameter(endDateAtr);
Date startDate;
Date endDate;
if (StringUtils.isBlank(startDateParam) || StringUtils.isBlank(endDateParam)) {
startDate = new Date();
endDate = DateUtils.addDays(startDate, 1);
} else {
endDate = DateUtil.parseYYYY_MM_dd(endDateParam);
startDate = DateUtil.parseYYYY_MM_dd(startDateParam);
}
Date yesterDay = DateUtils.addDays(startDate, -1);
long beginTime = NumberUtils.toLong(DateUtil.formatYYYYMMddHHMM(startDate));
long endTime = NumberUtils.toLong(DateUtil.formatYYYYMMddHHMM(endDate));
model.addAttribute(startDateAtr, startDateParam);
model.addAttribute(endDateAtr, endDateParam);
model.addAttribute("yesterDay", DateUtil.formatDate(yesterDay, "yyyy-MM-dd"));
return new TimeBetween(beginTime, endTime, startDate, endDate);
}
開發者ID:sohutv,項目名稱:cachecloud,代碼行數:23,
示例2: getFromAppCommandStats
點讚 3
import org.apache.commons.lang.time.DateUtils; //導入方法依賴的package包/類
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);
}
開發者ID:sohutv,項目名稱:cachecloud,代碼行數:24,
示例3: sendAppDailyEmail
點讚 3
import org.apache.commons.lang.time.DateUtils; //導入方法依賴的package包/類
@Override
public int sendAppDailyEmail() {
Date endDate = new Date();
Date startDate = DateUtils.addDays(endDate, -1);
int successCount = 0;
List 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;
}
開發者ID:sohutv,項目名稱:cachecloud,代碼行數:19,
示例4: appDaily
點讚 3
import org.apache.commons.lang.time.DateUtils; //導入方法依賴的package包/類
/**
* 應用日報查詢
*/
@RequestMapping("/daily")
public ModelAndView appDaily(HttpServletRequest request,
HttpServletResponse response, Model model, Long appId) throws ParseException {
// 1. 應用信息
AppDesc appDesc = appService.getByAppId(appId);
model.addAttribute("appDesc", appDesc);
// 2. 日期
String dailyDateParam = request.getParameter("dailyDate");
Date date;
if (StringUtils.isBlank(dailyDateParam)) {
date = DateUtils.addDays(new Date(), -1);
} else {
date = DateUtil.parseYYYY_MM_dd(dailyDateParam);
}
model.addAttribute("dailyDate", dailyDateParam);
// 3. 日報
AppDailyData appDailyData = appDailyDataCenter.getAppDailyData(appId, date);
model.addAttribute("appDailyData", appDailyData);
return new ModelAndView("app/appDaily");
}
開發者ID:sohutv,項目名稱:cachecloud,代碼行數:27,
示例5: getTimesheetByEmpIdEndDate
點讚 2
import org.apache.commons.lang.time.DateUtils; //導入方法依賴的package包/類
@Override
public Timesheet getTimesheetByEmpIdEndDate(long empId, Date timesheetEndDate) throws Exception {
logger.info("Inside getTimesheetByEndDateEmpId method of TimesheetDaoImpl---> " +
"empId: " + empId + " timesheetEndDate: " + timesheetEndDate);
Date todayDate = new Date();
List timesheetDetailsList = new ArrayList<>();
long timesheetDetailId = 110000;
Date weekStartDate = TimesheetDateUtils.parseDate("04/16/2017");
Date weekEndDate = DateUtils.addDays(weekStartDate, 7);
logger.info("weekStartDate: " + weekStartDate + " weekEndDate: " + weekEndDate);
SimpleDateFormat dayOfWeekFormat = new SimpleDateFormat("E"); // the day of the week abbreviated
SimpleDateFormat dayOfWeekDescFormat = new SimpleDateFormat("EEEE"); // the day of the week spelled out completely
//Check if the selected Date is before today's date
if (timesheetEndDate.before(todayDate)) {
for (int i = 1; i <= 7; ++i) {
Date weekDayDate = DateUtils.addDays(weekStartDate, 1);
logger.info("Week Day Date in the for loop: " + weekDayDate);
timesheetDetails = new TimesheetDetails(timesheetDetailId + 1, 111112, weekDayDate,
dayOfWeekFormat.format(weekDayDate), dayOfWeekDescFormat.format(weekDayDate),
8.0, 0.0, 0.0);
timesheetDetailsList.add(timesheetDetails);
}
timesheetObj = new Timesheet(999000, weekStartDate, weekEndDate, 1111001, "Timesheet for week.",
"Mahidhar", new Date(), "Mahidhar M", new Date(),
"SUBMITTED", timesheetDetailsList);
} else {
//Create an empty object and return it
timesheetObj = new Timesheet();
timesheetObj.setTimesheetDetailsList(timesheetDetailsList);
}
return timesheetObj;
}
開發者ID:Mahidharmullapudi,項目名稱:timesheet-expense-project,代碼行數:37,
示例6: FindAll
點讚 2
import org.apache.commons.lang.time.DateUtils; //導入方法依賴的package包/類
@Override
public List FindAll() {
String curDateString = DateFormatUtils.format(DateUtils.addDays(new Date(), config.getGenerateDate()),
"yyyy-MM-dd HH:mm:ss");
Date curDate = DateUtils.addDays(new Date(), config.getGenerateDate());
appDicts = daoDict.findAll();
screenImageList = daoScreenImage.findAll();
extendDataList = daoExtendData.findAll();
org.apache.velocity.Template templateVelocity = new VeTemplate(config.getAppGenerateTemplateBaseDir(),
"app.html").getTemplate();
Template template = new Template(config.getAppGenerateTemplateBaseDir(), "detail.html");
List list;
logger.debug("run time :{}", curDateString);
if (config.getGenerateDate() == 0) {
list = dao.findAll();
} else {
list = dao.findAll(curDate);
}
for (App app : list) {
setApp(app);
// genetatePage(app);
// genetatePage(app, template);
genetatePageVelocity(app, templateVelocity);
}
return list;
}
開發者ID:zhaoxi1988,項目名稱:sjk,代碼行數:28,
示例7: getIncrement
點讚 2
import org.apache.commons.lang.time.DateUtils; //導入方法依賴的package包/類
@Override
public Pager getIncrement(int currentPage, int pageSize, Short catalog) {
Assert.isTrue(pageSize > 0 && pageSize <= MAX_ROWS, "pageSize invalid!");
Assert.isTrue(currentPage > 0, "currentPage negative!");
// 因為在infoc 中 上報時將 type 2為應用,1為遊戲,所以為了和現有的一致,做一個轉換
if (null != catalog) {
catalog = catalog == (short) 1 ? (short) 2 : (short) 1;
}
Date date = DateUtils.addDays(new Date(), -1);
long totalCount = appMapper.getIncrementCount(catalog, date);
if (totalCount == 0) {
date = DateUtils.addDays(new Date(), -2);// 因為數據是淩晨 5點鍾導日昨天的數據,所以會出現
// 昨天數據不會出來的現象
totalCount = appMapper.getIncrementCount(catalog, date);
}
if (totalCount == 0) {
date = DateUtils.addDays(new Date(), -3);// 如果取前天的數據還是沒有,就去大後天的數據
totalCount = appMapper.getIncrementCount(catalog, date);
}
final int offset = HibernateHelper.firstResult(currentPage, pageSize);
Pager pager = new Pager();
pager.setRows(totalCount);
pager.setCurrentPage(currentPage);
pager.setPageSize(pageSize);
List list = appMapper.getIncrement(offset, pageSize, catalog, date);
pager.setResult(list);
return pager;
}
開發者ID:zhaoxi1988,項目名稱:sjk,代碼行數:29,
示例8: stat
點讚 2
import org.apache.commons.lang.time.DateUtils; //導入方法依賴的package包/類
@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 topLimitAppCommandStatsList = appStatsCenter.getTopLimitAppCommandStatsList(instanceInfo.getAppId(), Long.parseLong(startDateParam) * 10000, Long.parseLong(endDateParam) * 10000, 5);
model.addAttribute("appCommandStats", topLimitAppCommandStatsList);
}
return new ModelAndView("instance/instanceStat");
}
開發者ID:sohutv,項目名稱:cachecloud,代碼行數:29,
示例9: validateReturnsNullForUniqueDate
點讚 2
import org.apache.commons.lang.time.DateUtils; //導入方法依賴的package包/類
@Test
public void validateReturnsNullForUniqueDate() throws Exception {
Date date1 = new Date();
Date date2 = DateUtils.addDays(new Date(), 1);
assertThat(validator.validate(0, date1, Arrays.asList(newSplit(date1), newSplit(date2)))).isNullOrEmpty();
}
開發者ID:jonestimd,項目名稱:finances,代碼行數:8,
示例10: updateUpdatesFirstAcquired
點讚 2
import org.apache.commons.lang.time.DateUtils; //導入方法依賴的package包/類
@Test
public void updateUpdatesFirstAcquired() throws Exception {
SecuritySummary summary = new SecuritySummary(null, 2, BigDecimal.TEN, new Date(), BigDecimal.ONE, new BigDecimal(20));
SecuritySummary summary2 = new SecuritySummary(null, 2, BigDecimal.TEN, DateUtils.addDays(new Date(), -1), BigDecimal.ONE, new BigDecimal(20));
summary.update(summary2);
assertThat(summary.getFirstAcquired()).isEqualTo(summary2.getFirstAcquired());
}
開發者ID:jonestimd,項目名稱:finances,代碼行數:10,
示例11: fillWithValueDistriTime
點讚 2
import org.apache.commons.lang.time.DateUtils; //導入方法依賴的package包/類
/**
* 值分布日期格式
*/
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);
}
開發者ID:sohutv,項目名稱:cachecloud,代碼行數:33,
示例12: assembleMutilDateAppStatsJsonMinute
點讚 2
import org.apache.commons.lang.time.DateUtils; //導入方法依賴的package包/類
/**
* 多時間組裝
* @param appStats
* @param statName
* @param startDate
* @param endDate
* @return
*/
private String assembleMutilDateAppStatsJsonMinute(List appStats, String statName, Date startDate, Date endDate) {
if (appStats == null || appStats.isEmpty()) {
return "[]";
}
Map> map = new HashMap>();
Date currentDate = DateUtils.addDays(endDate, -1);
int diffDays = 0;
while (currentDate.getTime() >= startDate.getTime()) {
List list = new ArrayList();
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();
}
開發者ID:sohutv,項目名稱:cachecloud,代碼行數:37,
示例13: generateData
點讚 2
import org.apache.commons.lang.time.DateUtils; //導入方法依賴的package包/類
private void generateData() {
stockChartDs.refresh();
Date startDate = DateUtils.addDays(getZeroTime(new Date()), -MINUTES_COUNT);
for (int i = 0; i < MINUTES_COUNT; i++) {
stockChartDs.includeItem(addDateValueVolumeTime(DateUtils.addMinutes(startDate, i), i));
}
}
開發者ID:cuba-platform,項目名稱:sampler,代碼行數:9,
示例14: appDaily
點讚 2
import org.apache.commons.lang.time.DateUtils; //導入方法依賴的package包/類
@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("");
}
開發者ID:sohutv,項目名稱:cachecloud,代碼行數:29,
示例15: fillWithCostDateFormat
點讚 2
import org.apache.commons.lang.time.DateUtils; //導入方法依賴的package包/類
/**
* 獲取耗時時間區間
* @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);
}
開發者ID:sohutv,項目名稱:cachecloud,代碼行數:35,
示例16: holidayAsSeparateStrings
點讚 2
import org.apache.commons.lang.time.DateUtils; //導入方法依賴的package包/類
private static Set holidayAsSeparateStrings(Holiday holiday, Date startDate, Date endDate, String format) {
Date start;
Date end;
if (holiday.getStartDate().getTime() >= startDate.getTime()) {
start = holiday.getStartDate();
} else {
start = startDate;
}
if (holiday.getEndDate().getTime() <= endDate.getTime()) {
end = holiday.getEndDate();
} else {
end = endDate;
}
if (start.equals(startDate) && end.equals(endDate)) {
return Collections.emptySet();
} else {
Set stringDates = new HashSet<>();
DateFormat formatter = new SimpleDateFormat(format);
while (start.getTime() <= end.getTime()) {
stringDates.add(formatter.format(start));
start = DateUtils.addDays(start, 1);
}
return stringDates;
}
}
開發者ID:cuba-platform,項目名稱:sample-timesheets,代碼行數:28,
示例17: updateDayColumnsCaptions
點讚 2
import org.apache.commons.lang.time.DateUtils; //導入方法依賴的package包/類
protected void updateDayColumnsCaptions() {
for (Date current = firstDayOfWeek; current.getTime() <= lastDayOfWeek.getTime(); current = DateUtils.addDays(current, 1)) {
DayOfWeek day = DayOfWeek.fromCalendarDay(DateTimeUtils.getCalendarDayOfWeek(current));
String columnId = day.getId() + COLUMN_SUFFIX;
weeklyTsTable.setColumnCaption(columnId, ComponentsHelper.getColumnCaption(day.getId(), current));
}
}
開發者ID:cuba-platform,項目名稱:sample-timesheets,代碼行數:8,
示例18: index
點讚 2
import org.apache.commons.lang.time.DateUtils; //導入方法依賴的package包/類
@RequestMapping("/index")
public ModelAndView index(HttpServletRequest request, HttpServletResponse response, Model model, Integer admin, Long instanceId, Long appId, String tabTag) {
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);
if (instanceInfo == null) {
model.addAttribute("type", -1);
} else {
if (appId != null && appId > 0) {
model.addAttribute("appId", appId);
} else {
model.addAttribute("appId", instanceInfo.getAppId());
}
model.addAttribute("type", instanceInfo.getType());
}
} else {
}
if (tabTag != null) {
model.addAttribute("tabTag", tabTag);
}
return new ModelAndView("instance/instanceIndex");
}
開發者ID:sohutv,項目名稱:cachecloud,代碼行數:38,
示例19: advancedAnalysis
點讚 2
import org.apache.commons.lang.time.DateUtils; //導入方法依賴的package包/類
@RequestMapping("/advancedAnalysis")
public ModelAndView advancedAnalysis(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());
List topLimitAppCommandStatsList = appStatsCenter.getTopLimitAppCommandStatsList(instanceInfo.getAppId(), Long.parseLong(startDateParam) * 10000, Long.parseLong(endDateParam) * 10000, 5);
model.addAttribute("appCommandStats", topLimitAppCommandStatsList);
} else {
}
return new ModelAndView("instance/instanceAdvancedAnalysis");
}
開發者ID:sohutv,項目名稱:cachecloud,代碼行數:28,
示例20: triggerChartDate
點讚 2
import org.apache.commons.lang.time.DateUtils; //導入方法依賴的package包/類
@Override
public ReturnT> triggerChartDate() {
Date from = DateUtils.addDays(new Date(), -30);
Date to = new Date();
List triggerDayList = new ArrayList();
List triggerDayCountSucList = new ArrayList();
List triggerDayCountFailList = new ArrayList();
int triggerCountSucTotal = 0;
int triggerCountFailTotal = 0;
List> triggerCountMapAll = xxlJobLogDao.triggerCountByDay(from, to, -1);
List> triggerCountMapSuc = xxlJobLogDao.triggerCountByDay(from, to, ReturnT.SUCCESS_CODE);
if (CollectionUtils.isNotEmpty(triggerCountMapAll)) {
for (Map item: triggerCountMapAll) {
String day = String.valueOf(item.get("triggerDay"));
int dayAllCount = Integer.valueOf(String.valueOf(item.get("triggerCount")));
int daySucCount = 0;
int dayFailCount = dayAllCount - daySucCount;
if (CollectionUtils.isNotEmpty(triggerCountMapSuc)) {
for (Map sucItem: triggerCountMapSuc) {
String daySuc = String.valueOf(sucItem.get("triggerDay"));
if (day.equals(daySuc)) {
daySucCount = Integer.valueOf(String.valueOf(sucItem.get("triggerCount")));
dayFailCount = dayAllCount - daySucCount;
}
}
}
triggerDayList.add(day);
triggerDayCountSucList.add(daySucCount);
triggerDayCountFailList.add(dayFailCount);
triggerCountSucTotal += daySucCount;
triggerCountFailTotal += dayFailCount;
}
} else {
for (int i = 4; i > -1; i--) {
triggerDayList.add(FastDateFormat.getInstance("yyyy-MM-dd").format(DateUtils.addDays(new Date(), -i)));
triggerDayCountSucList.add(0);
triggerDayCountFailList.add(0);
}
}
Map result = new HashMap();
result.put("triggerDayList", triggerDayList);
result.put("triggerDayCountSucList", triggerDayCountSucList);
result.put("triggerDayCountFailList", triggerDayCountFailList);
result.put("triggerCountSucTotal", triggerCountSucTotal);
result.put("triggerCountFailTotal", triggerCountFailTotal);
return new ReturnT>(result);
}
開發者ID:mmwhd,項目名稱:stage-job,代碼行數:53,
示例21: findData
點讚 2
import org.apache.commons.lang.time.DateUtils; //導入方法依賴的package包/類
@Override
public void findData(boolean isAll) {
// 獲得所有分類
Map catalogs = dao.initCatalog();
// Map permissionsMap = dao.initPermissions();
// 獲得所有應用標簽
Map> AppTagsNormalTags = dao.initAppTags(TagType.NormalTag);
// 獲得所有專題
Map> AppTagsTopics = dao.initAppTags(TagType.TOPIC);
String curDateString = DateFormatUtils.format(DateUtils.addDays(new Date(), config.getGenerateDate()),
"yyyy-MM-dd HH:mm:ss");
Date curDate = DateUtils.addDays(new Date(), config.getGenerateDate());
org.apache.velocity.Template templateVelocity = new VeTemplate(config.getAppGenerateTemplateBaseDir(),
"app.html").getTemplate();
List list;
if (config.isDebug() && !isAll) {
logger.debug("It is test env.");
logger.debug("begin process {} data.", curDateString);
list = dao.findData(curDate);
int i = 0;
for (App app : list) {
if (i > 1000)
break;
genetatePageVelocity(app, templateVelocity, catalogs.get(app.getSubCatalog()), null,
AppTagsNormalTags.get(app.getId()), AppTagsTopics.get(app.getId()), isAll);
i++;
}
logger.info("generate size: {}", i);
list.clear();
} else {
long modfiyTime = templateVelocity.getLastModified();
long currDayTime = System.currentTimeMillis();
if ((currDayTime - modfiyTime) / (1000 * 60) <= 10 || isAll) {
logger.debug("generate all data.");
// 分頁獲取,分頁生成
int total = dao.count();
int rows = 10000;
int toatalPage = total % rows == 0 ? total / rows : total / rows + 1;
curDate = null;
// logger.info("all data,get data perPageSize,total:{},pages:{},paeSize:{},curentPgee:{}",
// new int[] { total, rows,
// toatalPage });
for (int i = 0; i < toatalPage; i++) {
list = dao.queryPager(total, i + 1, rows, null);// 全量生成,無需要傳入日期
logger.info("all data,total:{},paeSize:{},toatalPages:{},curentPgee:{}", new Integer[] { total,
rows, toatalPage, i + 1 });
// logger.info("curent pgee:{}", i);
genetatePageVelocity(catalogs, AppTagsNormalTags, AppTagsTopics, templateVelocity, list, isAll);
}
logger.info("generate size: {}", total);
} else {
logger.debug("part data. {} ", curDate);
list = dao.findData(curDate);
if (list != null) {
logger.info("generate size: {}", list.size());
}
isAll = false;
genetatePageVelocity(catalogs, AppTagsNormalTags, AppTagsTopics, templateVelocity, list, isAll);
list.clear();
}
// logger.debug("now : {}", new Date());
}
}
開發者ID:zhaoxi1988,項目名稱:sjk,代碼行數:75,
示例22: getIncrement
點讚 2
import org.apache.commons.lang.time.DateUtils; //導入方法依賴的package包/類
@Override
public List getIncrement(Short catalog) {
// Assert.isTrue(catalog >= 0, "catalog invalid");
// 因為在infoc 中 上報時將 type 2為應用,1為遊戲,所以為了和現有的一致,做一個轉換
if (null != catalog) {
catalog = catalog == (short) 1 ? (short) 2 : (short) 1;
}
Date date = DateUtils.addDays(new Date(), -1);
List list = appMapper.getIncrement(catalog, date);
if (list == null || list.size() < 20) {
date = DateUtils.addDays(new Date(), -2);// 因為數據是淩晨 5點鍾導日昨天的數據,所以會出現
// 昨天數據不會出來的現象
list = appMapper.getIncrement(catalog, date);
}
if (list == null || list.size() < 20) {
date = DateUtils.addDays(new Date(), -10);// 因為數據是淩晨
// 5點鍾導日昨天的數據,所以會出現
// 昨天數據不會出來的現象
list = appMapper.getIncrement(catalog, date);
}
if (CollectionUtils.isEmpty(list)) {
return new ArrayList(0);
}
// 對list 中的集合中 pkName進行排重
int len = list.size();
Set set = new HashSet(len);
List resultList = new ArrayList(len);
for (App4Summary app4Summary : list) {
if (set.contains(app4Summary.getPkname())) {
continue;
}
set.add(app4Summary.getPkname());
resultList.add(app4Summary);
}
list.clear();
set.clear();
return resultList;
}
開發者ID:zhaoxi1988,項目名稱:sjk,代碼行數:44,
示例23: getProgramEnrollmentEndDate
點讚 2
import org.apache.commons.lang.time.DateUtils; //導入方法依賴的package包/類
public Date getProgramEnrollmentEndDate()
{
return programEnrollmentEndDate != null ? DateUtils.addDays( programEnrollmentEndDate, 1 ) : programEnrollmentEndDate;
}
開發者ID:dhis2,項目名稱:dhis2-core,代碼行數:5,
示例24: createBillingCycleByDays
點讚 2
import org.apache.commons.lang.time.DateUtils; //導入方法依賴的package包/類
private BillingCycleVO createBillingCycleByDays(UserVO userVO, Integer numberOfDay) throws CoreException {
Date startDate = new Date();
Date endDate = DateUtils.addDays(startDate, numberOfDay);
return createNewBillCycle(userVO, startDate, endDate, 1);
}
開發者ID:SECQME,項目名稱:watchoverme-server,代碼行數:6,
示例25: createNewBillCycleWithTrial
點讚 2
import org.apache.commons.lang.time.DateUtils; //導入方法依賴的package包/類
private BillingCycleVO createNewBillCycleWithTrial(UserVO userVO) throws CoreException {
Date startDate = new Date();
Date endDate = DateUtils.addDays(startDate, userVO.getPackageVO().getTrialPeriod());
return createNewBillCycle(userVO, startDate, endDate, 1);
}
開發者ID:SECQME,項目名稱:watchoverme-server,代碼行數:7,
示例26: addDays
點讚 1
import org.apache.commons.lang.time.DateUtils; //導入方法依賴的package包/類
/**
* 給指定日期加幾天
*
* @param date
* 指定的日期
* @param numDays
* 需要往後加的天數
* @return 加好後的日期
*/
public static Date addDays(Date date, int numDays) {
Assert.notNull(date);
return DateUtils.addDays(date, numDays);
}
開發者ID:thinking-github,項目名稱:nbone,代碼行數:14,
注:本文中的org.apache.commons.lang.time.DateUtils.addDays方法示例整理自Github/MSDocs等源碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。