List of usage examples for java.util Date getTime
public long getTime()
From source file:Main.java
public static String format(Date d) { if (d == null || d.getTime() < ZERO_TIMESTAMP) return ""; Date now = new Date(); if (now.getYear() == d.getYear() && now.getMonth() == d.getMonth() && now.getDate() == d.getDate()) return FMT_TIME.format(d); else if (now.getYear() == d.getYear()) return FMT_DATE.format(d); else/* www . ja v a 2s. c o m*/ return FMT_DATE2.format(d); }
From source file:Main.java
public static String getWasteTime(Date startDate, Date endDate) { long wt = endDate.getTime() - startDate.getTime(); if (wt < 1000) { return wt + "ms"; } else if (wt < 60000) { long ms = wt % 1000; return ((wt - ms) / 1000) + "s " + ms + "ms"; } else {// w w w . j av a2 s .co m long ms = wt % 1000; long s = (wt - ms) % 60; return ((wt - s - ms) / 60000) + "m " + s + "s " + ms + "ms"; } }
From source file:Main.java
public static Time dateToSQLTime(java.util.Date d) { return d != null ? new Time(d.getTime()) : null; }
From source file:Main.java
public static void invokeMethodFormRed5(String toUserId) { Date nowDate = new Date(); String time = nowDate.getTime() + "" + (int) ((Math.random() * 100) % 100); message = time;/* ww w. ja v a 2 s.c o m*/ // connection.call("createMeeting", responder, User.id + "", toUserId, message); Log.d("DEBUG", "call createMeeting"); }
From source file:Main.java
/** * elapsedTimeDisplay/* w w w. j a va 2 s . co m*/ * Get the elapsed time between two dates in readable format * * @param dateStart the date start * @param dateEnd the date end * @return the elapsed hours and minutes */ public static String elapsedTimeDisplay(Date dateStart, Date dateEnd) { long diff = dateEnd.getTime() - dateStart.getTime(); long diffMinutes = diff / (60 * 1000) % 60; long diffHours = diff / (60 * 60 * 1000); String mins = Long.toString(diffMinutes); if (mins.length() == 1) { mins = "0" + mins; } return Long.toString(diffHours) + ":" + mins; }
From source file:DemoPreparedStatementSetDate.java
public static java.sql.Date getCurrentJavaSqlDate() { java.util.Date today = new java.util.Date(); return new java.sql.Date(today.getTime()); }
From source file:Main.java
public static String toModifiedTimeString(Date modified) { long time = modified.getTime(); double timed = time / 1000.0; String retval = String.format(Locale.ENGLISH, "%.2f", timed); // Dbg.debug("TIME: " + retval); return retval; }
From source file:Main.java
public static Date getNextDay(Date daDate, int iDays) { long lTime = daDate.getTime(); long lDay = 24 * 60 * 60 * 1000; for (int i = 0; i < iDays; i++) { lTime += lDay;/*from w ww .j av a 2s. c o m*/ } return new Date(lTime); }
From source file:Main.java
/** * Converts a date as long to a mac date as long * * @param date date to convert/*w w w. j av a 2s . c om*/ * @return date in mac format */ static public long convert(Date date) { return (date.getTime() / 1000L) + 2082844800L; }
From source file:Main.java
static void putDate(Bundle bundle, String key, Date date) { bundle.putLong(key, date.getTime()); }