Java Code Examples for org.apache.commons.lang.time.DateFormatUtils#format()
The following examples show how to use
org.apache.commons.lang.time.DateFormatUtils#format() .
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: ArchiveRepository.java From symphonyx with Apache License 2.0 | 6 votes |
/** * Gets the latest week archive (Sunday) with the specified time. * * @param time the specified time * @return archive, returns {@code null} if not found * @throws RepositoryException repository exception */ public JSONObject getWeekArchive(final long time) throws RepositoryException { final long weekEndTime = Times.getWeekEndTime(time); final String startDate = DateFormatUtils.format(time, "yyyyMMdd"); final String endDate = DateFormatUtils.format(weekEndTime, "yyyyMMdd"); final Query query = new Query().setCurrentPageNum(1).setPageCount(1). addSort(Archive.ARCHIVE_DATE, SortDirection.DESCENDING). setFilter(CompositeFilterOperator.and( new PropertyFilter(Archive.ARCHIVE_DATE, FilterOperator.GREATER_THAN_OR_EQUAL, startDate), new PropertyFilter(Archive.ARCHIVE_DATE, FilterOperator.LESS_THAN_OR_EQUAL, endDate) )); final JSONObject result = get(query); final JSONArray data = result.optJSONArray(Keys.RESULTS); if (data.length() < 1) { return null; } return data.optJSONObject(0); }
Example 2
Source File: IndexController.java From DataLink with Apache License 2.0 | 6 votes |
@RequestMapping(value = "/main") public ModelAndView main() throws Exception{ ModelAndView mav = new ModelAndView("main"); List<GroupInfo> groupList = groupService.getAllGroups(); ServerStatusMonitor monitor = ServerContainer.getInstance().getServerStatusMonitor(); List<ManagerMetaData> all = monitor.getAllAliveManagers(); ManagerMetaData active = monitor.getActiveManagerMetaData(); List<String> allManagerAddress = all.stream().map(ManagerMetaData::getAddress).collect(Collectors.toList()); String allManagers = Joiner.on(",").skipNulls().join(allManagerAddress); String activeManager = active == null ? null : active.getAddress(); String startTime = null; JvmSnapshot jvmSnapshot = JvmUtils.buildJvmSnapshot(); if (jvmSnapshot != null) { startTime = DateFormatUtils.format(jvmSnapshot.getStartTime(), "yyyy-MM-dd HH:mm:ss"); } mav.addObject("groupList", groupList); mav.addObject("allManagers", allManagers); mav.addObject("activeManager", activeManager); mav.addObject("startTime", startTime); return mav; }
Example 3
Source File: ActivityMgmtService.java From symphonyx with Apache License 2.0 | 5 votes |
/** * Bets 1A0001. * * @param userId the specified user id * @param amount the specified amount * @param smallOrLarge the specified small or large * @return result */ public synchronized JSONObject bet1A0001(final String userId, final int amount, final int smallOrLarge) { final JSONObject ret = Results.falseResult(); if (activityQueryService.is1A0001Today(userId)) { ret.put(Keys.MSG, langPropsService.get("activityParticipatedLabel")); return ret; } final String date = DateFormatUtils.format(new Date(), "yyyyMMdd"); final boolean succ = null != pointtransferMgmtService.transfer(userId, Pointtransfer.ID_C_SYS, Pointtransfer.TRANSFER_TYPE_C_ACTIVITY_1A0001, amount, date + "-" + smallOrLarge); ret.put(Keys.STATUS_CODE, succ); final String msg = succ ? langPropsService.get("activityBetSuccLabel") : langPropsService.get("activityBetFailLabel"); ret.put(Keys.MSG, msg); try { final JSONObject user = userQueryService.getUser(userId); final String userName = user.optString(User.USER_NAME); // Timeline final JSONObject timeline = new JSONObject(); timeline.put(Common.TYPE, Common.ACTIVITY); String content = langPropsService.get("timelineActivity1A0001Label"); content = content.replace("{user}", "<a target='_blank' rel='nofollow' href='" + Latkes.getServePath() + "/member/" + userName + "'>" + userName + "</a>"); timeline.put(Common.CONTENT, content); timelineMgmtService.addTimeline(timeline); } catch (final ServiceException e) { LOGGER.log(Level.ERROR, "Timeline error", e); } return ret; }
Example 4
Source File: ContentIdProcessor.java From javabase with Apache License 2.0 | 5 votes |
/** * 帖子最后更新日期,只能比较当前年份的的帖子 * 日期格式 11-20 8-25 17:33 * @param page * @param i * @return */ private String praseDate(Page page, int i) { String date= page.getHtml().xpath("//ul[@id='thread_list']/li[@class='j_thread_list clearfix'][" + (i) + "]//span[@class='threadlist_reply_date pull_right j_reply_data']/text()").toString(); if(!StringUtils.isEmpty(date)){ if(date.contains("-")) date=date.replace("-","").trim()+"0000"; //17:33 当天的帖子 if(date.contains(":")) date= DateFormatUtils.format(new Date(),"MMdd")+date.replace(":","").trim(); } return date; }
Example 5
Source File: DateUtils.java From uid-generator with Apache License 2.0 | 5 votes |
/** * Format date by 'yyyy-MM-dd' pattern * * @param date * @return */ public static String formatByDayPattern(Date date) { if (date != null) { return DateFormatUtils.format(date, DAY_PATTERN); } else { return null; } }
Example 6
Source File: DateUtils.java From Almost-Famous with MIT License | 5 votes |
/** * Format date by 'yyyy-MM-dd' pattern * * @param date * @return */ public static String formatByDayPattern(Date date) { if (date != null) { return DateFormatUtils.format(date, DAY_PATTERN); } else { return null; } }
Example 7
Source File: PollEventDO.java From projectforge-webapp with GNU General Public License v3.0 | 5 votes |
/** * @see org.projectforge.core.AbstractBaseDO#toString() */ @Override public String toString() { final String pattern = DateFormats.getFormatString(DateFormatType.DATE_TIME_MINUTES); return DateFormatUtils.format(startDate.getTime(), pattern) + " - " + DateFormatUtils.format(endDate.getTime(), pattern); }
Example 8
Source File: DateUtils.java From prong-uid with Apache License 2.0 | 5 votes |
/** * Format date by 'yyyy-MM-dd' pattern * * @param date * @return */ public static String formatByDayPattern(Date date) { if (date != null) { return DateFormatUtils.format(date, DAY_PATTERN); } else { return null; } }
Example 9
Source File: SepShowcases.java From sep4j with Apache License 2.0 | 4 votes |
public String getBirthDayString() { if (birthDay == null) { return null; } return DateFormatUtils.format(birthDay, "yyyy-MM-dd"); }
Example 10
Source File: SsioIntegrationTest.java From sep4j with Apache License 2.0 | 4 votes |
public String getDateStr() { if (date == null) { return null; } return DateFormatUtils.format(date, "yyyy-MM-dd HH:mm:ss"); }
Example 11
Source File: MysqlMethodInvocationHandler.java From Mycat2 with GNU General Public License v3.0 | 4 votes |
private SQLExpr invokeNow() { String time = DateFormatUtils.format(new Date(), "yyyy-MM-dd HH:mm:ss"); return new SQLIdentifierExpr(time); }
Example 12
Source File: DateUtil.java From ZTuoExchange_framework with MIT License | 4 votes |
public static String getDateRandom() { return DateFormatUtils.format(new Date(), "yyyyMMddHHmmss")+(int)((Math.random()*9+1)*10000); }
Example 13
Source File: WebsocketRequestImpl.java From huobi_Java with Apache License 2.0 | 4 votes |
WebsocketRequest<OrderListEvent> requestOrderListEvent( OrdersRequest ordersRequest, SubscriptionListener<OrderListEvent> subscriptionListener, SubscriptionErrorHandler errorHandler) { WebsocketRequest<OrderListEvent> request = new WebsocketRequest<>(subscriptionListener, errorHandler); request.name = "Order List Req for " + ordersRequest.getSymbol(); request.authHandler = (connection) -> { Account account = AccountsInfoMap.getUser(apiKey).getAccount(AccountType.SPOT); if (account == null) { throw new HuobiApiException(HuobiApiException.INPUT_ERROR, "[Input] No such account"); } String startDateString = ordersRequest.getStartDate() == null ? null : DateFormatUtils.format(ordersRequest.getStartDate(), "yyyy-MM-dd"); String endDateString = ordersRequest.getEndDate() == null ? null : DateFormatUtils.format(ordersRequest.getEndDate(), "yyyy-MM-dd"); JSONObject requestTopic = new JSONObject(); requestTopic.put("op", Channels.OP_REQ); requestTopic.put("topic", "orders.list"); requestTopic.put("account-id", account.getId()); requestTopic.put("symbol", ordersRequest.getSymbol()); requestTopic.put("types", ordersRequest.getTypesString()); requestTopic.put("states", ordersRequest.getStatesString()); requestTopic.put("start-date", startDateString); requestTopic.put("end-date", endDateString); requestTopic.put("from", ordersRequest.getStartId() != null ? ordersRequest.getStartId() + "" : null); requestTopic.put("direct", ordersRequest.getDirect() != null ? ordersRequest.getDirect().toString() : null); requestTopic.put("size", ordersRequest.getSize() != null ? ordersRequest.getSize() + "" : null); connection.send(requestTopic.toJSONString()); }; request.jsonParser = (jsonWrapper) -> { String ch = jsonWrapper.getString("topic"); OrderListEvent listEvent = new OrderListEvent(); listEvent.setTopic(ch); listEvent.setTimestamp(jsonWrapper.getLong("ts")); JsonWrapperArray dataArray = jsonWrapper.getJsonArray("data"); List<Order> orderList = new ArrayList<>(); dataArray.forEach(item -> { Order order = new Order(); order.setAccountType(AccountsInfoMap.getAccount(apiKey, item.getLong("account-id")).getType()); order.setAmount(item.getBigDecimal("amount")); order.setCanceledTimestamp(item.getLongOrDefault("canceled-at", 0)); order.setFinishedTimestamp(item.getLongOrDefault("finished-at", 0)); order.setOrderId(item.getLong("id")); order.setSymbol(item.getString("symbol")); order.setPrice(item.getBigDecimal("price")); order.setCreatedTimestamp(item.getLong("created-at")); order.setType(OrderType.lookup(item.getString("type"))); order.setFilledAmount(item.getBigDecimal("filled-amount")); order.setFilledCashAmount(item.getBigDecimal("filled-cash-amount")); order.setFilledFees(item.getBigDecimal("filled-fees")); order.setSource(OrderSource.lookup(item.getString("source"))); order.setState(OrderState.lookup(item.getString("state"))); order.setStopPrice(item.getBigDecimalOrDefault("stop-price", null)); order.setOperator(StopOrderOperator.find(item.getStringOrDefault("operator", null))); orderList.add(order); }); listEvent.setOrderList(orderList); return listEvent; }; return request; }
Example 14
Source File: DatumLeaseManager.java From sofa-registry with Apache License 2.0 | 4 votes |
private String format(long lastRenewTime) { return DateFormatUtils.format(lastRenewTime, "yyyy-MM-dd HH:mm:ss", TIME_ZONE); }
Example 15
Source File: DateUtils.java From prong-uid with Apache License 2.0 | 2 votes |
/** * Format date by 'yyyy-MM-dd HH:mm:ss' pattern * * @param date * @return */ public static String formatByDateTimePattern(Date date) { return DateFormatUtils.format(date, DATETIME_PATTERN); }
Example 16
Source File: DateUtils.java From prong-uid with Apache License 2.0 | 2 votes |
/** * Format date into string * * @param date * @param pattern * @return */ public static String formatDate(Date date, String pattern) { return DateFormatUtils.format(date, pattern); }
Example 17
Source File: DateUtils.java From Almost-Famous with MIT License | 2 votes |
/** * Format date by 'yyyy-MM-dd HH:mm:ss' pattern * * @param date * @return */ public static String formatByDateTimePattern(Date date) { return DateFormatUtils.format(date, DATETIME_PATTERN); }
Example 18
Source File: DateUtils.java From Almost-Famous with MIT License | 2 votes |
/** * Format date into string * * @param date * @param pattern * @return */ public static String formatDate(Date date, String pattern) { return DateFormatUtils.format(date, pattern); }
Example 19
Source File: ArticleQueryService.java From symphonyx with Apache License 2.0 | 2 votes |
/** * The demand format date. * * @param date the original date * @return the format date like "2015-08-03T07:26:57Z" */ private String formatDate(final Object date) { return DateFormatUtils.format(((Date) date).getTime(), "yyyy-MM-dd") + "T" + DateFormatUtils.format(((Date) date).getTime(), "HH:mm:ss") + "Z"; }
Example 20
Source File: CommentProcessor.java From symphonyx with Apache License 2.0 | 2 votes |
/** * The demand format date. * * @param date the original date * @return the format date like "2015-08-03T07:26:57Z" */ private String formatDate(final Object date) { return DateFormatUtils.format(((Date) date).getTime(), "yyyy-MM-dd") + "T" + DateFormatUtils.format(((Date) date).getTime(), "HH:mm:ss") + "Z"; }