posted 17 years ago
Here's the scoop: Calendar's getTime method returns a Date object:
Date getTime() //not the best method name, eh?
... and Date's state don't include a time zone. Its toString method implicitly uses your JVM's default time zone! WTF?!
To get around this, use a DateFormat, but don't forget to set it's TimeZone property first!
You can also avoid Calendar and go directly with Date if you just want the current date:
DateFormat df = DateFormat.getDateTimeInstance();
df.setTimeZone(TimeZone.getTimeZone("GMT"));
Date date = new Date();
System.out.println("now = " + date);
System.out.println("now in GMT = " + df.format(date));
[ April 03, 2006: Message edited by: Jeff Albertson ]
There is no emoticon for what I am feeling!