List of usage examples for java.util Date getTime
public long getTime()
From source file:edu.lternet.pasta.portal.search.AuthorSearch.java
/** * Boolean to determine whether the cache is due to be * refreshed. Returns true is the current time has advanced past the last * refresh time plus a time-to-live period. * /*from w w w.j a v a2 s . c o m*/ * @param lastRefreshTime the time when the cache was last refreshed */ private static boolean shouldRefresh(long lastRefreshTime) { double hours = 0.5; boolean shouldRefresh = false; final long timeToLive = (long) (hours * 60 * 60 * 1000); Date now = new Date(); long nowTime = now.getTime(); long refreshTime = lastRefreshTime + timeToLive; if (refreshTime < nowTime) { shouldRefresh = true; } return shouldRefresh; }
From source file:com.project.framework.util.DateUtils.java
/** * ?//ww w .j av a2s . co m * @param start * @param end * @return */ public static long dateReduction(Date start, Date end) { long l = end.getTime() - start.getTime(); return l / 1000 / 60; }
From source file:Main.java
public static String timeAgo(String iso8601) { SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ"); ParsePosition position = new ParsePosition(0); Date date = null; try {//w w w . j ava 2 s .co m date = simpleDateFormat.parse(iso8601.replaceFirst("Z", "+00:00"), position); } catch (Exception e) { System.out.println("could not parese date"); } String timeAgo = date == null ? "" : DateUtils.getRelativeTimeSpanString(date.getTime()).toString(); return timeAgo; }
From source file:com.mvdb.etl.actions.InitCustomerData.java
private static void initData(final OrderDAO orderDAO, final int batchCount, final int batchSize, final Date startDate, final Date endDate) { for (int batchIndex = 0; batchIndex < batchCount; batchIndex++) { final int batchIndexFinal = batchIndex; TimedExecutor te = new TimedExecutor() { @Override/* ww w .j av a 2 s.c o m*/ public void execute() { List<Order> orders = new ArrayList<Order>(); for (int recordIndex = 0; recordIndex < batchSize; recordIndex++) { Date createDate = RandomUtil.getRandomDateInRange(startDate, endDate); Date updateDate = new Date(); updateDate.setTime(createDate.getTime()); Order order = new Order(orderDAO.getNextSequenceValue(), RandomUtil.getRandomString(5), RandomUtil.getRandomInt(), createDate, updateDate); orders.add(order); } orderDAO.insertBatch(orders); System.out.println(String.format("Completed Batch %d of %d where size of batch is %s", batchIndexFinal + 1, batchCount, batchSize)); } }; long runTime = te.timedExecute(); System.out.println("Ran for seconds: " + runTime / 1000); } }
From source file:DateTimeUtil.java
/** * //from w w w.j av a 2 s . co m * @param startDate Interval start date time * @param endDate Interval end date time * @return Time interval in format hh:mm:ss */ public static String getTimeInterval(Date startDate, Date endDate) { long interval = (endDate.getTime() - startDate.getTime()); if (interval == 0) { return "00:00:00"; } long intervalSeconds = interval / 1000; long hours = intervalSeconds / 3600; long minutes = (intervalSeconds % 3600) / 60; long seconds = intervalSeconds % 60; String hoursText = String.valueOf(hours); if (hoursText.length() == 1) { hoursText = "0" + hoursText; } String minutesText = String.valueOf(minutes); if (minutesText.length() == 1) { minutesText = "0" + minutesText; } String secondsText = String.valueOf(seconds); if (secondsText.length() == 1) { secondsText = "0" + secondsText; } return hoursText + ":" + minutesText + ":" + secondsText; }
From source file:com.amazonaws.util.DateUtils.java
public static Date cloneDate(Date date) { return date == null ? null : new Date(date.getTime()); }
From source file:com.dianxin.imessage.common.util.DateUtil.java
/** * ??//from w w w .ja v a 2s. c om * * @return */ public static long getTimestamp() { Date dateNow = new Date(); return dateNow.getTime(); }
From source file:com.qcadoo.localization.api.utils.DateUtils.java
public static Date copy(final Date date) { if (date == null) { return null; }/*from ww w . j a v a2s . com*/ return new Date(date.getTime()); }
From source file:eu.europa.ec.grow.espd.xml.common.exporting.UblRequirementFactory.java
public static DateType buildDateType(Date date) { if (date == null) { return null; }//from ww w. j a v a 2 s .co m DateType dateType = new DateType(); dateType.setValue(new LocalDate(date.getTime())); return dateType; }
From source file:jp.co.nemuzuka.utils.DateTimeChecker.java
/** * ??.// w ww. j a v a 2s.c o m * ?????????? * @param refreshStartTime * @return ????true */ public static boolean isOverRefreshStartTime(Date refreshStartTime) { if (refreshStartTime == null) { return true; } long cuurentTime = CurrentDateUtils.getInstance().getCurrentDateTime().getTime(); long targetTime = refreshStartTime.getTime(); if (cuurentTime > targetTime) { return true; } return false; }