List of utility methods to do TimeZone Get
Map | getFilteredTimeZoneMap() Get time zones. if (timezoneIDMap == null) { timezoneIDMap = new LinkedHashMap<String, String>(); String[] ids = TimeZone.getAvailableIDs(); for (String id : ids) { TimeZone zone = TimeZone.getTimeZone(id); int offset = zone.getRawOffset(); int offsetSecond = offset / CONSTANT_1000; int hour = offsetSecond / (CONSTANT_60 * CONSTANT_60); ... |
void | getHostDefaultValues() get Host Default Values tz = TimeZone.getDefault(); defaultID = tz.getID(); defaultRawOffset = tz.getRawOffset(); |
int | getHourPart(TimeZone timeZone) Returns the hour part of a time zone. int offset = timeZone.getRawOffset(); int tzHour = offset / 3600000; return tzHour; |
TimeZone | getJapanTimeZone() get Japan Time Zone return TimeZone.getTimeZone(TIME_ZONE_JAPAN);
|
String | getMediumDisplayDate(Date moment, TimeZone tz, Locale inLocale) Get the displayable date and time string for the given moment in time, in the given timezone, localized in medium style. return getMediumDisplayDate(moment, tz, inLocale, true);
|
String | getMicrosoftTimeZoneName(TimeZone timeZone) Convert Olson TimeZone to Microsoft TimeZone Generated using Unicode CLDR project Example: https://gist.github.com/scottmac/655675e9b4d4913c539c return olsonTimeZoneToMs.get(timeZone.getID());
|
char | getMilitaryTimeZoneCharacter(TimeZone tz) get Military Time Zone Character int offset = tz.getOffset(System.currentTimeMillis()); int offsetHours = offset / MILLISECONDS_IN_HOUR; if (0 != offset % MILLISECONDS_IN_HOUR || 12 < offsetHours || -12 > offsetHours) { return 'J'; } else { if (0 == offsetHours) { return 'Z'; } else if (0 < offsetHours) { ... |
long | getMillis(TimeZone tz, int year, int month, int day, int hour, int minute, int second, int millis) Calculate the milliseconds since 1970-01-01 (UTC) for the given date and time (in the specified timezone). try { return getTimeTry(false, tz, year, month, day, hour, minute, second, millis); } catch (IllegalArgumentException e) { String message = e.toString(); if (message.indexOf("HOUR_OF_DAY") > 0) { if (hour < 0 || hour > 23) { throw e; return getTimeTry(true, tz, year, month, day, hour, minute, second, millis); } else if (message.indexOf("DAY_OF_MONTH") > 0) { int maxDay; if (month == 2) { maxDay = new GregorianCalendar().isLeapYear(year) ? 29 : 28; } else { maxDay = 30 + ((month + (month > 7 ? 1 : 0)) & 1); if (day < 1 || day > maxDay) { throw e; hour += 6; return getTimeTry(true, tz, year, month, day, hour, minute, second, millis); } else { return getTimeTry(true, tz, year, month, day, hour, minute, second, millis); |
Calendar | getMoscowCalendar() get Moscow Calendar return new GregorianCalendar(getMoscowTimeZone()); |
TimeZone | getMoscowTimeZone() get Moscow Time Zone return java.util.TimeZone.getTimeZone("Europe/Moscow"); |