List of utility methods to do Calendar Time
Date | getClientCurrentDate(final Calendar calendar, final TimeZone timeZone) Get current date according to client's time zone. Calendar result = new GregorianCalendar(timeZone); result.setTimeInMillis(calendar.getTimeInMillis() + timeZone.getOffset(calendar.getTimeInMillis()) - TimeZone.getDefault().getOffset(calendar.getTimeInMillis())); result.getTime(); return result.getTime(); |
String | getCurrentTimeDecimal(Calendar cal) get Current Time Decimal return String.format("%04d%02d%02d%02d%02d%02d.%03d", cal.get(Calendar.YEAR), cal.get(Calendar.MONTH) + 1, cal.get(Calendar.DAY_OF_MONTH), cal.get(Calendar.HOUR_OF_DAY), cal.get(Calendar.MINUTE), cal.get(Calendar.SECOND), cal.get(Calendar.MILLISECOND)); |
Date | getCurrentTimeIfCalendareIsNull(Calendar testDate) Returns the testDate if it has a value otherwise returns the current time. if (testDate == null) { return Calendar.getInstance().getTime(); } else { return testDate.getTime(); |
long | getCurrentTimeLongType(Calendar cal) get Current Time Long Type String dateString = String.format("%04d%02d%02d%02d%02d%02d%03d", cal.get(Calendar.YEAR), cal.get(Calendar.MONTH) + 1, cal.get(Calendar.DAY_OF_MONTH), cal.get(Calendar.HOUR_OF_DAY), cal.get(Calendar.MINUTE), cal.get(Calendar.SECOND), cal.get(Calendar.MILLISECOND)); return Long.valueOf(dateString); |
Calendar | getCurrentTimeZoneCalendar(String timeZone) Gets the current time zone calendar. Calendar calendar = Calendar.getInstance(TimeZone.getTimeZone(timeZone));
return calendar;
|
Date | getDateTimeByDate(Date date, int calendarType, int qty) get Date Time By Date Calendar now = Calendar.getInstance();
now.setTime(date);
now.set(calendarType, now.get(calendarType) + qty);
return now.getTime();
|
String | getFullTimeToString(Calendar argCal) Return [HH]h[mm]-[ss]-[ms] Calendar cal = argCal; if (cal == null) { cal = new GregorianCalendar(); String date = getTimeToString(cal) + FULL_TIME_SEPARATOR; if (cal.get(Calendar.SECOND) < 10) { date += "0"; date += cal.get(Calendar.SECOND) + FULL_TIME_SEPARATOR; if (cal.get(Calendar.MILLISECOND) < 10) { date += "0"; if (cal.get(Calendar.MILLISECOND) < 100) { date += "0"; date += cal.get(Calendar.MILLISECOND); return date; |
long | getLocalTime(Calendar calendar) Return the milliseconds passed since 1.1.1970 00:00:00.000 [TimeZone] return calendar.getTimeInMillis() + calendar.getTimeZone().getOffset(calendar.getTimeInMillis());
|
Calendar | getMaxTimeCalendar(Calendar source) get Max Time Calendar Calendar calendar = Calendar.getInstance();
calendar.set(source.get(Calendar.YEAR), source.get(Calendar.MONTH), source.get(Calendar.DAY_OF_MONTH), 23,
59, 59);
return calendar;
|
long | getTime(Calendar c) get Time return c.getTimeInMillis();
|