List of utility methods to do TimeZone Add
SimpleTimeZone | addTimeZone(String id, double off) Add a java.util.SimpleTimeZone int offset = (new Double(off * 3600000)).intValue(); SimpleTimeZone tz = new SimpleTimeZone(offset, id); s_timeZoneTable.put(id, tz); return tz; |
long | adjustTimeToDefaultTimezone(long time) Shift the time from UTC to the local timezone return time + getDefaultTimeZoneOffset();
|
Date | baseFor(TimeZone tz) base For Calendar c = Calendar.getInstance(tz);
c.clear();
c.set(1899, 11, 30, 0, 0, 0);
return c.getTime();
|
Calendar | cal(TimeZone tz) cal Calendar cal = (tz != null) ? new GregorianCalendar(tz) : new GregorianCalendar(); cal.clear(); return cal; |
boolean | isAfter(int month1, int day1, int year1, int hour1, int minute1, int amPm1, int month2, int day2, int year2, int hour2, int minute2, int amPm2, TimeZone timeZone, Locale locale) is After Calendar cal1 = new GregorianCalendar(timeZone, locale); cal1.set(Calendar.MONTH, month1); cal1.set(Calendar.DATE, day1); cal1.set(Calendar.YEAR, year1); cal1.set(Calendar.HOUR, hour1); cal1.set(Calendar.MINUTE, minute1); cal1.set(Calendar.AM_PM, amPm1); Calendar cal2 = new GregorianCalendar(timeZone, locale); ... |
boolean | isFuture(int month, int year, TimeZone timeZone, Locale locale) is Future Calendar curCal = new GregorianCalendar(timeZone, locale); curCal.set(Calendar.DATE, 1); Calendar cal = (Calendar) curCal.clone(); cal.set(Calendar.MONTH, month); cal.set(Calendar.YEAR, year); return cal.after(curCal); |
int | millisFromEpochToHourId(long millis, TimeZone tz) Convert from millis to hour id Calendar cal = Calendar.getInstance(tz);
cal.setTimeInMillis(millis);
return calendarToHourId(cal);
|
Calendar | nowWithTimeZone(TimeZone timezone) now With Time Zone return Calendar.getInstance(timezone);
|
long | removeTimeZoneOffset(long t) remove Time Zone Offset return t - getTimeZoneOffset(t);
|
Date | shiftDate(Date date, TimeZone timeZone, String pattern) shift Date if ((timeZone == null) || (date == null)) return date; SimpleDateFormat sdf = new SimpleDateFormat(pattern); String s = sdf.format(date); sdf.setTimeZone(timeZone); try { return sdf.parse(s); } catch (ParseException e) { ... |