List of utility methods to do Calendar Millisecond
Calendar | calendar(long millis) calendar Calendar calendar = Calendar.getInstance();
calendar.setTimeInMillis(millis);
return calendar;
|
long | calendarToGMTMillis(Calendar cal) Convert a calendar object to a long in the form of milliseconds since the epoch of January 1, 1970. Date date = cal.getTime(); long time = date.getTime(); return time; |
long | calendarToGMTMillis(Calendar cal) Convert a calendar object to a long in the form of milliseconds since the epoch of January 1, 1970. Date date = cal.getTime(); TimeZone tz = cal.getTimeZone(); int offset = tz.getOffset(date.getTime()); long time; if (offset != 0) { Calendar gmtCal = Calendar.getInstance(TimeZone.getTimeZone("GMT")); gmtCal.setTime(date); gmtCal.add(Calendar.MILLISECOND, offset); ... |
void | clearCalendarMillisecond(Calendar cal) clear Calendar Millisecond cal.set(Calendar.MILLISECOND, cal.getActualMinimum(Calendar.MILLISECOND)); |
long | elapsedMillis(Calendar before, Calendar after) Retrieve the amount of elapsed milliseconds between the two given calendars. return elapsedMillis(before, after, 1);
|
Calendar | getCalendarXDaysFromY(long startTimeInMillis, int daysFromStartDate) get Calendar X Days From Y Calendar cal = Calendar.getInstance();
cal.setTimeInMillis(startTimeInMillis);
cal.add(Calendar.DAY_OF_YEAR, daysFromStartDate);
return cal;
|
long | getDateMilliseconds(Calendar pDate) get Date Milliseconds return pDate.getTimeInMillis();
|
Calendar | getLastMilli(Calendar cal) Returns the last millisecond of the given day the day (2008/03/07 15:23:32 992ms --> 2008/03/07 23:59:59 999ms) Calendar ret = new GregorianCalendar(cal.get(Calendar.YEAR), cal.get(Calendar.MONTH), cal.get(Calendar.DAY_OF_MONTH), 23, 59, 59); ret.set(Calendar.MILLISECOND, 999); return ret; |
int | getMillisecond(Calendar calendar) get Millisecond return calendar.get(Calendar.MILLISECOND);
|
int | getMilliSinceMidnight(Calendar arg) gets the number of milliseconds since Midnight of the current day (UTC) of the argument int millis = arg.get(Calendar.HOUR_OF_DAY) * 60 * 60 * 1000; millis = millis + arg.get(Calendar.MINUTE) * 60 * 1000; millis = millis + arg.get(Calendar.SECOND) * 1000; millis = millis + arg.get(Calendar.MILLISECOND); return millis; |