List of utility methods to do ZoneId
ZoneId | determineTimeZoneId(String zoneId) determine Time Zone Id try { return ZoneId.of(zoneId); } catch (Exception e) { return ZoneId.systemDefault(); |
LocalDateTime | fromEpochMilliseconds(final Long fromEpoch) from Epoch Milliseconds return LocalDateTime.ofInstant(Instant.ofEpochMilli(fromEpoch), systemDefaultZoneId);
|
ZoneId | getDefaultTimeZone() get Default Time Zone return ZoneId.systemDefault();
|
ZoneId | getDefaultZoneId() Returns the default zone id used dor user interface (UI) return defaultZoneId;
|
ZoneId | getDefaultZoneId() get Default Zone Id ZoneId zone = null; try { try { String id = System.getProperty("user.timezone"); if (id != null) { zone = ZoneId.of(id); } catch (RuntimeException ex) { ... |
ZoneId | getRequestTimeZone(String timestamp) Return the ZoneId of given ISO8601 timestamp return ZonedDateTime.parse(timestamp).getZone();
|
ZoneId | getTimezone(String tzid) Get the ZoneId of a String that could be a valid tzid. try { return ZoneId.of(tzid); } catch (Exception e) { return ZoneId.of("America/New_York"); |
ZoneId | getTimeZoneId(final TimeZone tz) Get time zone id .ZoneId.SHORT_IDS used get id if time zone is abbreviated like 'IST'. return ZoneId.of(tz.getID(), ZoneId.SHORT_IDS);
|
ZonedDateTime | getZoneDateTime(Date d, String tzId) get Zone Date Time long milli = (d == null ? new Date() : d).getTime(); return Instant.ofEpochMilli(milli).atZone(getZoneId(tzId)); |
ZoneId | getZoneId() get Zone Id return ZoneId.systemDefault();
|