aspose file tools*
The moose likes Java in General and the fly likes Reg: Retriveing timezone from timestamp Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Reg: Retriveing timezone from timestamp " Watch "Reg: Retriveing timezone from timestamp " New topic
Author

Reg: Retriveing timezone from timestamp

Chethan Sharma
Ranch Hand

Joined: Mar 22, 2006
Posts: 59
Hi,

I have a requirement to parse the timestamp and get the timezone from it:

timestamp is in the format of 'Thu Mar 11 18:25:14 GMT-08:00 2010'.

From this string, I need to get the timezone (as PST in above example).

I am using the SimpleDateFormat as 'EEE MMM dd HH:mm:ss z yyyy' for parsing but the timezone is showing as IST.

following is the code i have tried :
/**
SimpleDateFormat SDF = new SimpleDateFormat("EEE MMM dd HH:mm:ss z yyyy");
String testdate = "Thu Mar 11 18:25:14 GMT-08:00 2010";
SDF.parse(testdate);
System.out.println("SDF.getTimeZone().getDisplayName());
**/

Output:
==========
India Standard Time.

if I rewrite 'testdate' with "Thu Mar 11 18:25:14 PST 2010", output is coming correctly as 'PST'.

Please let me know how to retireve the correct timezone in the above code ?

Also, I have tried taking timezone substring from the testdate as 'GMT-08:00' and pass it to TimeZone class like :
/**
System.out.println(TimeZone.getTimeZone("GMT-08:00").getID());
**/
But the output is shown as 'GMT-08:00' but not the 'PST'.

Please help me to achieve the desired output.


chaithu
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Reg: Retriveing timezone from timestamp