Java Utililty Methods ZoneId

List of utility methods to do ZoneId

Description

The list of methods to do ZoneId are organized into topic(s).

Method

ZoneIddetermineTimeZoneId(String zoneId)
determine Time Zone Id
try {
    return ZoneId.of(zoneId);
} catch (Exception e) {
    return ZoneId.systemDefault();
LocalDateTimefromEpochMilliseconds(final Long fromEpoch)
from Epoch Milliseconds
return LocalDateTime.ofInstant(Instant.ofEpochMilli(fromEpoch), systemDefaultZoneId);
ZoneIdgetDefaultTimeZone()
get Default Time Zone
return ZoneId.systemDefault();
ZoneIdgetDefaultZoneId()
Returns the default zone id used dor user interface (UI)
return defaultZoneId;
ZoneIdgetDefaultZoneId()
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) {
...
ZoneIdgetRequestTimeZone(String timestamp)
Return the ZoneId of given ISO8601 timestamp
return ZonedDateTime.parse(timestamp).getZone();
ZoneIdgetTimezone(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");
ZoneIdgetTimeZoneId(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);
ZonedDateTimegetZoneDateTime(Date d, String tzId)
get Zone Date Time
long milli = (d == null ? new Date() : d).getTime();
return Instant.ofEpochMilli(milli).atZone(getZoneId(tzId));
ZoneIdgetZoneId()
get Zone Id
return ZoneId.systemDefault();