List of utility methods to do TimeZone Get
String | getCurrentTimezoneOffset() get Current Timezone Offset TimeZone tz = TimeZone.getDefault(); Calendar cal = GregorianCalendar.getInstance(tz); int offsetInMillis = tz.getOffset(cal.getTimeInMillis()); String offset = String.format("%02d:%02d", Math.abs(offsetInMillis / 3600000), Math.abs((offsetInMillis / 60000) % 60)); offset = (offsetInMillis >= 0 ? "+" : "-") + offset; return offset; |
Calendar | getDateInTimeZone(final Date date, final TimeZone timeZone) Get date in timezone final Calendar calendar = Calendar.getInstance(timeZone); calendar.setTime(date); return calendar; |
long | getDefaultTimeZoneOffset() Get the offset between GMT and the local timezone long offset = 0; TimeZone zn = TimeZone.getDefault(); Calendar local = Calendar.getInstance(); local.setTime(new Date(System.currentTimeMillis())); int time = (int) (local.get(Calendar.HOUR_OF_DAY) * HOUR_FACTOR + local.get(Calendar.MINUTE) * MINUTE_FACTOR + local.get(Calendar.SECOND) * SECOND_FACTOR); offset = zn.getOffset(1, local.get(Calendar.YEAR), local.get(Calendar.MONTH), local.get(Calendar.DAY_OF_MONTH), ... |
int | getDefaultTimeZoneRawOffset() get Default Time Zone Raw Offset return TimeZone.getDefault().getRawOffset();
|
String | getDefaultTimeZoneString() get Default Time Zone String if (timeZone == null) { String s = new SimpleDateFormat("Z").format(new Date(0)); timeZone = s.substring(0, 3) + ':' + s.substring(3, 5); return timeZone; |
int | getDiffTimeZoneRawOffset(String timeZoneId) get Diff Time Zone Raw Offset return TimeZone.getDefault().getRawOffset() - TimeZone.getTimeZone(timeZoneId).getRawOffset();
|
String | getDisplayDate(Date date, TimeZone tz, Locale inLocale, int style, boolean includeTime) Private method for getting display date for a particular style: short, medium, long or full. if (date == null || inLocale == null) { return null; if (includeTime && (tz == null)) { tz = TimeZone.getTimeZone("GMT"); try { SimpleDateFormat formatter; ... |
int | getDSTSavings(TimeZone tz) Equivalent of TimeZone.getDSTSavings() in JDK 1.4, but Quartz is trying to support JDK 1.3. if (tz.useDaylightTime()) { return 3600000; return 0; |
long | getDSTTime(TimeZone tz, Date date) get DST Time return date.getTime() + (tz.inDaylightTime(date) ? tz.getDSTSavings() : 0);
|
String | getEnd(String date, TimeZone tz) get End return date + " 23:59:59 " + tz.getDisplayName(true, TimeZone.SHORT); |