• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Get date and time using TimeZone.

Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ranchers,

Can I get the perfect date and time at a perticular location with the help of TimeZone?

The code I am using is:

The output is:
Eastern Standard Time
Date:Sun Dec 26 13:34:51 IST 2010
Press any key to continue . . .

I am trying to get the date and time at the specified TimeZone (Eastern Standard Time) but I am getting the system date and time.
Am I making any mistake in the code? Please guide me.

Thanks and regards,
Ranch Hand
Posts: 1179
Mac OS X Eclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The Three-letter time zone IDs are deprecated, therefore you are better of by using the long zone id - eg. "America/Los_Angeles".

The TimeZone isn't been shown on a Date object, because it has no information on it - but it is stored on the Calendar object, therefore you need to use this information when you want to show the correct Date/Time by using SimpleDateFormat.

It's just a flesh wound! Or a tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
    Bookmark Topic Watch Topic
  • New Topic