• Post Reply Bookmark Topic Watch Topic
  • New Topic

Reg: Retriveing timezone from timestamp  RSS feed

Chethan Sharma
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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";

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 :
But the output is shown as 'GMT-08:00' but not the 'PST'.

Please help me to achieve the desired output.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!