List of usage examples for java.util Calendar getTimeInMillis
public long getTimeInMillis()
From source file:Main.java
public static String getCurrentDateString() { Calendar currentCalendar = Calendar.getInstance(); currentYear = currentCalendar.get(Calendar.YEAR); return dateFormat.format(currentCalendar.getTimeInMillis()); }
From source file:Main.java
public static long getEndOfCurrentWeek() { Calendar calendar = getCalendarWithTime(getStartOfCurrentWeek()); calendar.add(Calendar.DATE, 6); return calendar.getTimeInMillis(); }
From source file:Main.java
public static long getTimeMillisAt(int hour, int minute) { Calendar today = Calendar.getInstance(); today.set(Calendar.HOUR_OF_DAY, hour); today.set(Calendar.MINUTE, minute); return today.getTimeInMillis(); }
From source file:edu.cwru.apo.Auth.java
public static long getTimestamp() { Calendar cal = Calendar.getInstance(); return cal.getTimeInMillis(); }
From source file:Main.java
public static long getYesterTime() { Calendar calendar = Calendar.getInstance(); calendar.setTime(new Date()); calendar.add(Calendar.DAY_OF_MONTH, -1); return calendar.getTimeInMillis(); }
From source file:Main.java
static int dateDiff(int type, Calendar fromDate, Calendar toDate, boolean future) { int diff = 0; long savedDate = fromDate.getTimeInMillis(); while ((future && !fromDate.after(toDate)) || (!future && !fromDate.before(toDate))) { savedDate = fromDate.getTimeInMillis(); fromDate.add(type, future ? 1 : -1); diff++;/*from w ww . j av a2s .c om*/ } diff--; fromDate.setTimeInMillis(savedDate); return diff; }
From source file:Main.java
/** * Returns the previous day of the passed {@link Date} * * @return The date - 24 hours/* ww w .ja va 2 s. c o m*/ */ public static Date getYesterday(Date date) { if (date == null) { return getYesterday(new Date()); } Calendar cal = Calendar.getInstance(); cal.setTime(date); cal.add(Calendar.DAY_OF_WEEK, -1); return new Date(cal.getTimeInMillis()); }
From source file:Main.java
public static int getInterval(long timeInMillis, long currentTimeInMillis) { Calendar calendar = Calendar.getInstance(); calendar.setTimeInMillis(currentTimeInMillis); Long timeInMillisInterval = timeInMillis - calendar.getTimeInMillis(); Float x = Float.valueOf(timeInMillisInterval) / 1000 / 3600 / 24; return (int) Math.ceil(x); }
From source file:Main.java
public static String formatMediumDate(Context context, Calendar date) { return getAbbrevDayOfWeekString(date.get(Calendar.DAY_OF_WEEK)) + ", " + DateUtils.formatDateTime(context, date.getTimeInMillis(), DateUtils.FORMAT_NUMERIC_DATE); }
From source file:Main.java
/** * Get Calendar from Date//ww w.ja v a 2 s . com * @param cal Calendar * @return Calendar generated */ public static Calendar generateCalendar(Calendar cal) { Calendar c = Calendar.getInstance(); c.setTimeInMillis(cal.getTimeInMillis()); return c; }