com.jeesuite.common.util.DateUtils Java Examples
The following examples show how to use
com.jeesuite.common.util.DateUtils.
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: TopicPartitionInfo.java From jeesuite-libs with Apache License 2.0 | 6 votes |
public String getFormatLastTime(){ if(getLastTime() == null)return null; long diffSeconds = DateUtils.getDiffSeconds(new Date(), getLastTime()); if(diffSeconds >= 86400){ return (diffSeconds/86400) + " 天前"; } if(diffSeconds >= 3600){ return (diffSeconds/3600) + " 小时前"; } if(diffSeconds >= 60){ return (diffSeconds/60) + " 分钟前"; } return diffSeconds + " 秒前"; }
Example #2
Source File: ConfigStateHolder.java From jeesuite-config with Apache License 2.0 | 5 votes |
private static void clearExpireNodes(String appName,String profile){ try { List<ConfigState> sameAppNodes = configStates.get(appName + "#" + profile); if(sameAppNodes == null || sameAppNodes.isEmpty())return; String syncType = sameAppNodes.get(0).syncType; String zkPath = sameAppNodes.get(0).zkPath; Date nowTime = new Date(); if(!SYNC_TYPE_HTTP.equals(syncType)){ List<String> activeNodes = getZkClient(profile).getChildren(zkPath); if(activeNodes == null)return; if(activeNodes.isEmpty()){ sameAppNodes.clear(); return; } Iterator<ConfigState> iterator = sameAppNodes.iterator(); while (iterator.hasNext()) { ConfigState c = iterator.next(); if (!activeNodes.contains(c.getNodeId())) { logger.info("remove expire node:{}",c.getNodeId()); iterator.remove(); }else{ c.setSyncTime(nowTime); } } }else{ synchronized (sameAppNodes) { Iterator<ConfigState> iter = sameAppNodes.iterator(); while (iter.hasNext()) { ConfigState s = iter.next(); if (DateUtils.getDiffSeconds(nowTime, s.syncTime) > s.syncIntervalSeconds * 2) { iter.remove(); } } } } } catch (Exception e) { logger.error("clearExpireNodes_error",e); } }
Example #3
Source File: CountByExampleProvider.java From jeesuite-libs with Apache License 2.0 | 5 votes |
/** * @param whereBuilder * @param column * @param value */ private void appendWhere(StringBuilder whereBuilder, ColumnMapper column, Object value) { if(whereBuilder.length() > 0)whereBuilder.append(" AND "); whereBuilder.append(column.getColumn()).append("="); if(column.getJavaType() == String.class){ whereBuilder.append("'").append(value).append("'"); }else if(column.getJavaType() == Date.class){ whereBuilder.append("'").append(DateUtils.format((Date)value)).append("'"); }else{ whereBuilder.append(value); } }
Example #4
Source File: SelectByExampleProvider.java From jeesuite-libs with Apache License 2.0 | 5 votes |
/** * @param whereBuilder * @param column * @param value */ private void appendWhere(StringBuilder whereBuilder, ColumnMapper column, Object value) { if(whereBuilder.length() > 0)whereBuilder.append(" AND "); whereBuilder.append(column.getColumn()).append("="); if(column.getJavaType() == String.class){ whereBuilder.append("'").append(value).append("'"); }else if(column.getJavaType() == Date.class){ whereBuilder.append("'").append(DateUtils.format((Date)value)).append("'"); }else{ whereBuilder.append(value); } }
Example #5
Source File: CacheExpires.java From jeesuite-libs with Apache License 2.0 | 4 votes |
/** * 当前时间到今天结束相隔的秒 * @return */ public static long todayEndSeconds(){ Date curTime = new Date(); return DateUtils.getDiffSeconds(DateUtils.getDayEnd(curTime), curTime); }
Example #6
Source File: DemoTask2.java From jeesuite-libs with Apache License 2.0 | 4 votes |
@Override public void doJob(JobContext context) throws Exception { System.out.println("\n=============\nDemoTask_2=====>"+context.getNodeId()+"--"+DateUtils.format(new Date())+"\n===============\n"); Thread.sleep(RandomUtils.nextLong(1000, 2000)); }
Example #7
Source File: DemoTask.java From jeesuite-libs with Apache License 2.0 | 4 votes |
@Override public void doJob(JobContext context) throws Exception { System.out.println("\n=============\nDemoTask_1=====>"+context.getNodeId()+"--"+DateUtils.format(new Date())+"\n===============\n"); Thread.sleep(RandomUtils.nextLong(1000, 2000)); }