participate


Internationalization (I18N) - TimeZone ID validation
This question is not answered.

<<   Back to Forum  |   Give us Feedback
This topic has 1 reply on 1 page.
KapilGhodawat
Posts:25
Registered: 9/28/06
TimeZone ID validation   
Oct 21, 2009 12:06 AM
 
 
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.
 
DrClap
Posts:38,747
Registered: 4/30/99
Re: TimeZone ID validation   
Oct 21, 2009 9:43 AM (reply 1 of 1)  (In reply to original post )
 
 
A quick look at the API documentation reveals that TimeZone.getAvailableIDs() returns an array of the valid time zone IDs. You could write a little bit of code which checks that your string is in that array of strings.
 
This topic has 1 reply on 1 page.
Back to Forum
 
Read the Developer Forums Code of Conduct

Click to email this message Email this Topic

Edit this Topic
  
 
 
Forums Statistics
    Users Online : 62
  • Guests : 128

About Sun forums
  • Sun Forums is a large collection of user generated discussions. It is here to help you ask questions, find answers, and participate in discussions.

    Check out our guide on Getting started with Sun Forums for a full walkthrough of how to best leverage the benefits of this community.

Powered by Jive Forums