1 Reply Latest reply on Oct 21, 2009 4:43 PM by DrClap

    TimeZone ID validation

    843810
      java.util.TimeZone.getTimeZone(id) method takes a String parameter that is called timeZoneID.
      As per the method comments it will return GMT if given id can not be understood.

      My question is, Does Java provide any method to validate the timeZone ID that is to be supplied to this method. Or is there any other method available which return null or throws exception if timeZone ID can not be understood instead of returning GMT timeZone.

      I don't want to write my own validation method which checks the given id against TimeZone.getAvailableIDs() as id can be a customized ID like GMT+8, GMT+05:30 or UTC+1 etc. and for correect handling of all such cases I have to add number of ifs and else in the method.

      What I am looking for is a full proof method for validating the timeZoneID.