List of usage examples for java.util Date getTime
public long getTime()
From source file:gov.nih.nci.cadsr.cadsrpasswordchange.core.CommonUtil.java
public static long calculateDays(Date dateEarly, Date dateLater) { return (dateLater.getTime() - dateEarly.getTime()) / (24 * 60 * 60 * 1000); }
From source file:Main.java
public static String getTime() { String re_time = null;//from w w w. j a v a 2s. c o m long currentTime = System.currentTimeMillis(); SimpleDateFormat sdf = new SimpleDateFormat("yyyy.MM.dd"); Date d; d = new Date(currentTime); long l = d.getTime(); String str = String.valueOf(l); re_time = str.substring(0, 10); return re_time; }
From source file:Main.java
public static boolean showMessageTime(String currentTime, String prevTime) { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); try {//from w ww . ja v a2 s. co m Date currentDate = sdf.parse(currentTime); Date prevDate = sdf.parse(prevTime); if (currentDate.getTime() - prevDate.getTime() >= 300000) { return true; } } catch (Exception e) { e.printStackTrace(); } return false; }
From source file:com.pinterest.deployservice.common.CommonUtils.java
public static Long convertDateStringToMilliseconds(String dateString) throws Exception { SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:SS"); Date date = formatter.parse(dateString); return date.getTime(); }
From source file:Main.java
public static long getQuot(String time1, String time2) { long quot = 0; SimpleDateFormat ft = new SimpleDateFormat("yyyy/MM/dd"); try {/*from w ww .j a v a 2 s. co m*/ Date date1 = ft.parse(time1); Date date2 = ft.parse(time2); quot = date1.getTime() - date2.getTime(); quot = quot / 1000 / 60 / 60 / 24; } catch (ParseException e) { e.printStackTrace(); } return quot; }
From source file:Main.java
/** * Convenience method to format a Date as an XML DateTime String. * * @param date/*from w ww.ja v a 2 s . c om*/ * the date to format. * @return the XML representation as a string. */ public static String formatDate(final Date date) { GregorianCalendar calendar = new GregorianCalendar(); calendar.setTimeInMillis(date.getTime()); return formatGregorianCalendar(calendar); }
From source file:Main.java
public static boolean judgeCurrTime(String time) { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm"); Date date = new Date(); try {//w w w . j a va 2s .co m date = sdf.parse(time); long t = date.getTime(); long round = System.currentTimeMillis(); if (t - round > 0) { return true; } else { return false; } } catch (Exception e) { e.printStackTrace(); } return false; }
From source file:Main.java
public static boolean isMediaInDateRange(String mediaTimeStamp) { if (!TextUtils.isEmpty(mediaTimeStamp)) { Date currentDate = new Date(); long mediaDateLong = Long.valueOf(mediaTimeStamp) * 1000L; long diff = currentDate.getTime() - mediaDateLong; if (diff < IG_MEDIA_PHOTOS_RANGE) { return true; }/*from w ww . j a v a 2 s . c om*/ } return false; }
From source file:Main.java
public static long compareMin(Date before, Date after) { if (before == null || after == null) { return 0l; }/*w w w . jav a 2 s.c o m*/ long dif = 0; if (after.getTime() >= before.getTime()) { dif = after.getTime() - before.getTime(); } else if (after.getTime() < before.getTime()) { dif = after.getTime() + 86400000 - before.getTime(); } dif = Math.abs(dif); return dif / 60000; }
From source file:Main.java
public static String getHumanInterval(Date start, Date end) { if (end == null) { return "ongoing"; }/*from w w w. ja va 2s .c o m*/ long t = end.getTime() - start.getTime(); if (t < 1000) { return t + "ms"; } t /= 1000; if (t < 60) { return t + " seconds"; } t /= 60; if (t < 60) { return t + " minutes"; } t /= 60; if (t < 24) { return t + " hours"; } t /= 24; if (t < 7) { return t + " days"; } long weeks = t / 7; if (t < 365) { return weeks + " weeks"; } t /= 365; return t + " years"; }