Java TimeZone String Parse parseTimeZoneId(String timeZoneId)

Here you can find the source of parseTimeZoneId(String timeZoneId)

Description

parse Time Zone Id

License

Apache License

Declaration

public static TimeZone parseTimeZoneId(String timeZoneId) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.util.TimeZone;

public class Main {
    public static TimeZone parseTimeZoneId(String timeZoneId) {
        TimeZone zone = TimeZone.getDefault();
        String zoneName = "";
        if (null != timeZoneId && !"".equals(timeZoneId)) {
            timeZoneId = timeZoneId.trim().replaceAll("\\s+", "");

            int index2 = timeZoneId.indexOf(")");
            if (index2 >= 0) {
                zoneName = timeZoneId.substring(index2 + 1, timeZoneId.length()).trim();
            }//from   w  ww  .j  a  va2 s  . c  o m
            zone = TimeZone.getTimeZone(zoneName);
        }
        return zone;
    }
}

Related

  1. guessTimeZone(String timezoneOffset)
  2. parseCal(long time, TimeZone to)
  3. parseDA(TimeZone tz, String s)
  4. parseTimeZoneString(String timeZoneString)
  5. parseTimeZoneString(String timeZoneString)
  6. safeTimeZone(String s)