List of utility methods to do TimeZone Usage
boolean | isSameDayOfMillis(final long ms1, final long ms2) is Same Day Of Millis final long interval = ms1 - ms2; return interval < MILLIS_IN_DAY && interval > -1L * MILLIS_IN_DAY && toDay(ms1) == toDay(ms2); |
boolean | isTimeZoneDisponible(TimeZone timeZone) Verifica si una TimeZone esta disponible para su uso String[] timeZonesIds = TimeZone.getAvailableIDs(); for (String timeZoneId : timeZonesIds) { if (timeZoneId.equals(timeZone.getID())) { return true; return false; |
boolean | isValidTimeZone(final String timeZone) is Valid Time Zone if (timeZone.equals("GMT")) { return true; } else { String id = TimeZone.getTimeZone(timeZone).getID(); if (!id.equals("GMT")) { return true; return false; |
boolean | isValidTimezone(String tz) is Valid Timezone if (null != tz) { return Arrays.asList(TimeZone.getAvailableIDs()).contains(tz); return false; |
TimeZone | localeToTimeZone(Locale locale) locale To Time Zone return localeTimeZoneMap.get(locale);
|
String | localTimeZoneString() local Time Zone String return TimeZone.getDefault().getID();
|
Calendar | mergeTime(Calendar date, Date time) Set the TIME (Hour, Minute and Second) values for the start (and end mergeTime if set) to match the mergeTime (HMS) values of the given date value. Calendar timeCalendar = Calendar.getInstance(TIMEZONE_UTC);
timeCalendar.setTime(time);
return mergeTime(date, timeCalendar);
|
long | offset(long time) Gets the current timezone offset return TimeZone.getDefault().getOffset(time);
|
TimeZone | parseBackendTimeZone(String timeZone) Converts backend's TimeZone parameter to java format. if (timeZone.startsWith("GMT")) { TimeZone tz = GMT_ZONES.get(timeZone); if (tz != null) { return tz; return TimeZone.getTimeZone(timeZone); |
void | runInTimeZone(TimeZone timeZone, Runnable action) run In Time Zone TimeZone originalZone = TimeZone.getDefault(); try { TimeZone.setDefault(timeZone); action.run(); } finally { TimeZone.setDefault(originalZone); |