Java TimeZone Usage parseBackendTimeZone(String timeZone)

Here you can find the source of parseBackendTimeZone(String timeZone)

Description

Converts backend's TimeZone parameter to java format.

License

Open Source License

Parameter

Parameter Description
timeZone time zone to use

Return

java TimeZone

Declaration

public static TimeZone parseBackendTimeZone(String timeZone) 

Method Source Code

//package com.java2s;
/*//from   ww  w  .  j a  v a 2 s . c  o  m
 * Copyright (c) 2003, PostgreSQL Global Development Group
 * See the LICENSE file in the project root for more information.
 */

import java.util.HashMap;

import java.util.TimeZone;

public class Main {
    private static final HashMap<String, TimeZone> GMT_ZONES = new HashMap<String, TimeZone>();

    /**
     * Converts backend's TimeZone parameter to java format.
     * Notable difference: backend's gmt-3 is GMT+03 in Java.
     *
     * @param timeZone time zone to use
     * @return java TimeZone
     */
    public static TimeZone parseBackendTimeZone(String timeZone) {
        if (timeZone.startsWith("GMT")) {
            TimeZone tz = GMT_ZONES.get(timeZone);
            if (tz != null) {
                return tz;
            }
        }
        return TimeZone.getTimeZone(timeZone);
    }
}

Related

  1. isValidTimezone(String tz)
  2. localeToTimeZone(Locale locale)
  3. localTimeZoneString()
  4. mergeTime(Calendar date, Date time)
  5. offset(long time)
  6. runInTimeZone(TimeZone timeZone, Runnable action)
  7. serializeTimeZone(TimeZone timeZone)
  8. setBelarusTimeZone()
  9. stringToTimeZone(String tzString)