Java Utililty Methods TimeZone To

List of utility methods to do TimeZone To

Description

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

Method

TimeZonecreateTimeZoneFromDouble(double timeZoneOffsetInHours)
create Time Zone From Double
long offsetInMinutes = Math.round(timeZoneOffsetInHours * 60d);
if (offsetInMinutes == 0) {
    return TimeZone.getTimeZone("GMT");
return TimeZone.getTimeZone(getTimeZoneString(offsetInMinutes * minutesToMillis));
DateextractTimeZone(String strdate, Date thedate)
extract Time Zone
String tzSign = strdate.substring(strdate.length() - 6, strdate.length() - 5);
String tzHour = strdate.substring(strdate.length() - 5, strdate.length() - 3);
String tzMin = strdate.substring(strdate.length() - 2);
if (tzSign.equals("-") || tzSign.equals("+")) {
    int h = Integer.parseInt(tzHour);
    int m = Integer.parseInt(tzMin);
    if (tzSign.equals("+")) {
        h = -1 * h;
...
TimeZoneparseTimeZoneString(String timeZoneString)
Parse the given timeZoneString value into a TimeZone .
TimeZone timeZone = TimeZone.getTimeZone(timeZoneString);
if ("GMT".equals(timeZone.getID()) && !timeZoneString.startsWith("GMT")) {
    throw new IllegalArgumentException("Invalid time zone specification '" + timeZoneString + "'");
return timeZone;
voidsetTimeZone(String name)
Temporarily sets the default system timezone to the specified timezone ID.
systemTimeZone.set(TimeZone.getDefault());
TimeZone.setDefault(TimeZone.getTimeZone(name));
StringtimeZoneToCode(TimeZone tz)
time Zone To Code
return timeZoneToString(tz);
StringtimeZoneToString(TimeZone tz)
time Zone To String
return tz != null ? tz.getID() : "";
DatetoLocalTZ(Date time, TimeZone localTimeZone)
to Local TZ
if (localTimeZone == null) {
    return time;
return new Date(time.getTime() + (localTimeZone.getRawOffset() - TimeZone.getDefault().getRawOffset()));