List of usage examples for java.util Calendar getTimeInMillis
public long getTimeInMillis()
From source file:Main.java
public static String getCurrentMonth() { Calendar calendar = Calendar.getInstance(); long currentTime = calendar.getTimeInMillis(); SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM"); calendar.setTimeInMillis(currentTime); return formatter.format(calendar.getTime()); }
From source file:Main.java
public static String getCreateTime() { String createtime = null;//from w ww . j a v a 2 s .co m Calendar calendar = new GregorianCalendar(); createtime = Long.toString(calendar.getTimeInMillis()); return createtime; }
From source file:Main.java
public static Long generateTimeStamp() { Calendar calendar = Calendar.getInstance(TimeZone.getTimeZone("UTC")); return calendar.getTimeInMillis() / 1000L; }
From source file:Main.java
public static long CompareMilliTimeDelta(String arrivalTime) { Calendar calendarToday = Calendar.getInstance(); long millisecondsCurrent = calendarToday.getTimeInMillis(); return millisecondsCurrent - Long.parseLong(arrivalTime); }
From source file:Main.java
/** * Returns a String formatted in the default locale of the device. Looks like "Ddd, Mmm dd, H:MMTT - H:MMTT * @param context the {@link android.content.Context} that this is running within. * @param start the starting date and time of this entry. * @param end the ending date and time of this entry. *///from w w w . java2 s. c o m public static String buildTimeEntryDateAndTime(Context context, Calendar start, Calendar end) { return DateUtils.formatDateRange(context, start.getTimeInMillis(), end.getTimeInMillis(), DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_ABBREV_MONTH | DateUtils.FORMAT_SHOW_TIME | DateUtils.FORMAT_SHOW_WEEKDAY | DateUtils.FORMAT_ABBREV_WEEKDAY | DateUtils.FORMAT_NO_YEAR); }
From source file:Main.java
public static long getTimeDiff(Calendar cal1, Calendar cal2) { if (cal1 == null || cal2 == null) return 0; return cal2.getTimeInMillis() - cal1.getTimeInMillis(); }
From source file:Main.java
public static int getDistanceMinute(Calendar cFrom, Calendar cTo) { int distance = 0; ;//w ww . j av a 2 s. c o m long from = cFrom.getTimeInMillis(); long to = cTo.getTimeInMillis(); long resultSeconds = to - from; distance = (int) (resultSeconds / (60 * 1000)); return distance; }
From source file:Main.java
/** * /* w w w . j a va 2s .c o m*/ * @param year * @param month * @param day * @return */ public static long getTimemillis(int year, int month, int day) { Calendar cal = Calendar.getInstance(); cal.set(year, month, day); return cal.getTimeInMillis(); }
From source file:Main.java
public static long getTimeLong(int year, int month, int day) { Calendar calendar = Calendar.getInstance(); calendar.set(year, month, day);//from w w w .j a v a 2s . c om return calendar.getTimeInMillis(); }
From source file:Main.java
public static int daysBetween(java.sql.Date date1, java.sql.Date date2) { Calendar cal = Calendar.getInstance(); cal.setTime(date1);//from ww w.j a v a 2 s . c om long time1 = cal.getTimeInMillis(); cal.setTime(date2); long time2 = cal.getTimeInMillis(); long between_days = (time2 - time1) / (1000 * 3600 * 24); return Integer.parseInt(String.valueOf(between_days)); }