List of usage examples for org.apache.commons.lang3.time DateFormatUtils format
public static String format(final Calendar calendar, final String pattern)
Formats a calendar into a specific pattern.
From source file:mase.stat.RunTimeStat.java
private void consoleStats(EvolutionState state) { long eta = eta(state); Date etaDate = new Date(System.currentTimeMillis() + eta); state.output.message("Gen: " + DurationFormatUtils.formatDuration(totalGenTime, "mm:ss.SSS") + " | Run: " + DurationFormatUtils.formatDuration(System.currentTimeMillis() - runStartTime, "HH:mm:ss") + " | ETA: " + DateFormatUtils.format(etaDate, "HH:mm:ss") + " [" + DurationFormatUtils.formatDuration(eta, "HH:mm:ss") + "]\n"); }
From source file:com.eryansky.modules.disk.utils.DiskUtils.java
/** * FTP//from w w w. j a va 2 s. com * @param folder * @param userId * @return */ public static String getFTPStoreDir(Folder folder, String userId) { Date now = Calendar.getInstance().getTime(); String _S = "/"; StringBuffer path = new StringBuffer(); path.append(DateFormatUtils.format(now, "yyyy")).append(_S); String folderAuthorize = FolderAuthorize.getFolderAuthorize(folder.getFolderAuthorize()).toString() .toLowerCase(); path.append(userId).append(_S).append(folderAuthorize).append(_S); if (FolderAuthorize.User.getValue().equals(folder.getFolderAuthorize())) { path.append(folder.getId()); } else if (FolderAuthorize.Organ.getValue().equals(folder.getFolderAuthorize())) { path.append(folder.getOrganId()).append(_S).append(folder.getId()); } else if (FolderAuthorize.Role.getValue().equals(folder.getFolderAuthorize())) { path.append(folder.getRoleId()).append(_S).append(folder.getId()); } else if (FolderAuthorize.Public.getValue().equals(folder.getFolderAuthorize())) { path.append(folder.getId()); } else if (FolderAuthorize.SysTem.getValue().equals(folder.getFolderAuthorize())) { path.append(folder.getCode()); } return path.toString(); }
From source file:com.netsteadfast.greenstep.bsc.util.HistoryItemScoreReportContentQueryUtils.java
public static List<String> getLineChartCategories(String dateVal, int dataSize) throws Exception { List<String> categories = new LinkedList<String>(); if (dataSize < 0) { throw new ServiceException("data-size error!"); }//from ww w. j av a 2 s . c o m Date endDate = DateUtils.parseDate(dateVal, new String[] { "yyyyMMdd" }); int dateRange = dataSize - 1; if (dateRange < 0) { dateRange = 0; } if (dateRange == 0) { categories.add(DateFormatUtils.format(endDate, "yyyy/MM/dd")); return categories; } Date startDate = DateUtils.addDays(endDate, (dateRange * -1)); for (int i = 0; i < dataSize; i++) { Date currentDate = DateUtils.addDays(startDate, i); String currentDateStr = DateFormatUtils.format(currentDate, "yyyy/MM/dd"); categories.add(currentDateStr); } return categories; }
From source file:com.daphne.es.personal.calendar.web.controller.CalendarController.java
@RequestMapping(value = "/move", method = RequestMethod.POST) @ResponseBody/* www . j a v a 2 s . c o m*/ public String moveCalendar(@RequestParam("id") Long id, @RequestParam(value = "start", required = false) @DateTimeFormat(pattern = dataFormat) Date start, @RequestParam(value = "end", required = false) @DateTimeFormat(pattern = dataFormat) Date end) { Calendar calendar = calendarService.findOne(id); if (end == null) { end = start; } calendar.setStartDate(start); calendar.setLength((int) Math.ceil(1.0 * (end.getTime() - start.getTime()) / oneDayMillis)); if (DateUtils.isSameDay(start, end)) { calendar.setLength(1); } if (!"00:00:00".equals(DateFormatUtils.format(start, "HH:mm:ss"))) { calendar.setStartTime(start); } if (!"00:00:00".equals(DateFormatUtils.format(end, "HH:mm:ss"))) { calendar.setEndTime(end); } calendarService.copyAndRemove(calendar); return "ok"; }
From source file:cn.mypandora.util.MyDateUtils.java
/** * ?/*w w w. j a va 2 s .c om*/ * * @return */ public static String getCurrentMonth() { Calendar cal = Calendar.getInstance(); String currentMonth = DateFormatUtils.format(cal, MONTH_FORMAT); return currentMonth; }
From source file:com.luna.personal.calendar.web.controller.CalendarController.java
@RequestMapping(value = "/move", method = RequestMethod.POST) @ResponseBody/*from w w w.ja va 2s .c o m*/ public String moveCalendar(@RequestParam("id") Long id, @RequestParam(value = "start", required = false) @DateTimeFormat(pattern = dataFormat) Date start, @RequestParam(value = "end", required = false) @DateTimeFormat(pattern = dataFormat) Date end) { Calendar calendar = calendarService.findOne(id); if (end == null) { end = start; } calendar.setStartDate(start); calendar.setLength((int) Math.ceil(1.0 * (end.getTime() - start.getTime()) / oneDayMillis)); if (DateUtils.isSameDay(start, end)) { calendar.setLength(1); } if (!"00:00:00".equals(DateFormatUtils.format(start, "HH:mm:ss"))) { calendar.setStartTime(start); } if (!"00:00:00".equals(DateFormatUtils.format(end, "HH:mm:ss"))) { calendar.setEndTime(end); } try { calendarService.copyAndRemove(calendar); } catch (Exception e) { log.error("", e); } return "ok"; }
From source file:com.hbc.api.trade.fund.GFundWithdrawController.java
@RequestMapping(value = "v1.0/g/account/withdraw/history", method = RequestMethod.GET, produces = "application/json; charset=utf-8") public ReturnResult withdraw_history(FundAccountLogParam param) { int totalHistoryCount = 0; //final String pattern = "{0}{1}"; List<GFundWithdrawHistory> histories = new ArrayList<GFundWithdrawHistory>(); FundValidator.validateParamString(param.getAccountNo(), "AccountNo"); @SuppressWarnings("unchecked") List<Integer> bizTypeList = Arrays .asList(new Integer[] { BizType.RECHARAGE.value, BizType.BOSS_RECHARAGE.value, BizType.REWARD_BY_YINGDAOYOU.value, BizType.INVITEREWORD.value, BizType.REWARD_BY_MIS.value, BizType.PUNISH_BY_MIS.value, BizType.WITHDRAW_APPLY.value, BizType.WITHDRAW_DENY.value, BizType.PICKUP.value, BizType.TRANSFER.value, BizType.DAILY.value, BizType.SINGLE.value, BizType.CANCAL_TRANSFER.value, BizType.CANCAL_DAILY.value, BizType.CANCLE_SINGLE.value, BizType.CANCAL_COMMNENDATION.value }); List<FundAccountLog> historyAccountLogs = fundAccountLogService .getAccountAllLogsByType(param.getAccountNo(), bizTypeList, param.getLimit(), param.getOffset()); if (historyAccountLogs != null && historyAccountLogs.size() > 0) { totalHistoryCount = fundAccountLogService.getAccountAllLogsSizeByType(param.getAccountNo(), bizTypeList);/*www . j a v a 2s . c om*/ Iterator<FundAccountLog> fundAccountLogIterator = historyAccountLogs.iterator(); while (fundAccountLogIterator.hasNext()) { String orderNo; FundAccountLog fundAccountLog = fundAccountLogIterator.next(); GFundWithdrawHistory history = new GFundWithdrawHistory(); if (fundAccountLog.getBizType() != null) { history.setContent(BizType.getType(fundAccountLog.getBizType()).name); } if (StringUtils.isNoneBlank(orderNo = fundAccountLog.getOrderNo())) { history.setOrderNo(orderNo); } history.setAccountLogNo(fundAccountLog.getLogNo()); history.setBizComment(fundAccountLog.getBizStatus() == 1 ? "?" : ""); history.setCreateTime(DateFormatUtils.format(fundAccountLog.getCreateTime(), DATE_FORMAT)); history.setPrice(String.valueOf(fundAccountLog.getChangAmount())); histories.add(history); } } ReturnResult returnResult = new ReturnResult(); returnResult.setData(histories, totalHistoryCount); return returnResult; }
From source file:cn.org.awcp.core.utils.DateUtils.java
/** * ?<br>//from ww w . j a v a 2 s.c o m * generate by: vakin jiang at 2012-3-7 * * @param dateStr * @param patterns * @return */ public static String formatDateStr(String dateStr, String... patterns) { String pattern = YYYY_MM_DD_HH_MM_SS; if (patterns != null && patterns.length > 0 && StringUtils.isNotBlank(patterns[0])) { pattern = patterns[0]; } return DateFormatUtils.format(parseDate(dateStr), pattern); }
From source file:com.framework.demo.web.controller.calendar.CalendarController.java
@RequestMapping(value = "/move", method = RequestMethod.POST) @ResponseBody//from w w w .j a va 2 s . c o m public String moveCalendar(@RequestParam("id") Long id, @RequestParam(value = "start", required = false) @DateTimeFormat(pattern = dataFormat) Date start, @RequestParam(value = "end", required = false) @DateTimeFormat(pattern = dataFormat) Date end) { PersonalCalendar calendar = calendarService.findById(id); if (end == null) { end = start; } calendar.setStartDate(start); calendar.setLength((int) Math.ceil(1.0 * (end.getTime() - start.getTime()) / oneDayMillis)); if (DateUtils.isSameDay(start, end)) { calendar.setLength(1); } if (!"00:00:00".equals(DateFormatUtils.format(start, "HH:mm:ss"))) { calendar.setStartTime(start); } if (!"00:00:00".equals(DateFormatUtils.format(end, "HH:mm:ss"))) { calendar.setEndTime(end); } calendarService.updateEntity(calendar); return "ok"; }
From source file:cn.mypandora.util.MyDateUtils.java
/** * ?//from w w w .j a va 2 s . co m * * @return */ public static String getCurrentDate() { Calendar cal = Calendar.getInstance(); String currentDate = DateFormatUtils.format(cal, DATE_FORMAT); return currentDate; }