0

This sentence is supposed to get time information at Chicago time zone:

Calendar.getInstance(TimeZone.getTimeZone("America/Chicago")).getTime();

My problem is no matter what string I put in getTimeZone(), result would be changed.

Could anyone explain this situation?

Eric
  • 200
  • 6
WangMango
  • 35
  • 5

1 Answers1

0

The key thing to understand is that a java.util.Date represents UTC only - it has no time zone information. Time zones are presentation layer only - they are used to figure out how to display the time represented by the java.util.Date.

So if you use SimpleDateFormat or the Calendar.get(...) methods, the time zone will be taken into account.

Jason
  • 11,744
  • 3
  • 42
  • 46
  • Thank you for help. But I wanna ask if getTimeZone() is not the right method to use, which method should I choose? It would be great help to explain why my code doesn't work. – WangMango Nov 01 '13 at 18:20