NOTE: Submitting again after subscribing to Joda. Hi,
I have a simple use case to convert a date from local to GMT and vice versa. Here is the snippet of my code and its output. /public static Date convertLocalToGMT(Date localDate) { DateTime dateTime = new DateTime(localDate); System.out.println("Current Local Date :" + dateTime.toDate()); System.out.println("Current Local Date In Millis :" + dateTime.toDate().getTime()); DateTime gmt = dateTime.withZoneRetainFields(DateTimeZone.forID("Etc/GMT")); System.out.println("GMT Date :" + gmt.toDate()); System.out.println("GMT Date In Millis :" + gmt.toDate().getTime()); DateTime gmt1 = dateTime.withZone(DateTimeZone.forID("Etc/GMT")); System.out.println("GMT Date :" + gmt1.toDate()); System.out.println("GMT Date In Millis :" + gmt1.toDate().getTime()); DateTime gmt2 = dateTime.toDateTime(DateTimeZone.forID("Etc/GMT")); System.out.println("GMT Date :" + gmt2.toDate()); System.out.println("GMT Date In Millis :" + gmt2.toDate().getTime()); /* long dm = localDate.getTime(); System.out.println(); long gmtm = gmt.getMillis(); System.out.println(); */ Date d = gmt.toDate(); System.out.println(); return d; } / The output of this is as follows: *Current Local Date :Fri Mar 30 11:26:10 PDT 2012 Current Local Date In Millis :1333131970483 GMT Date :Fri Mar 30 04:26:10 PDT 2012 GMT Date In Millis :1333106770483 GMT Date :Fri Mar 30 11:26:10 PDT 2012 GMT Date In Millis :1333131970483 GMT Date :Fri Mar 30 11:26:10 PDT 2012 GMT Date In Millis :1333131970483* Here is my main method to invoke the api: / public static void main(String[] args) { convertLocalToGMT(new Date()); } / What I don't understand is why the conversion is not happening from local to GMT. Please advise. Thanks, Jeet -- View this message in context: http://joda-interest.219941.n2.nabble.com/Resubmitting-Issue-with-converting-the-dates-between-different-timzones-tp7430308p7430308.html Sent from the Joda-Interest mailing list archive at Nabble.com. ------------------------------------------------------------------------------ This SF email is sponsosred by: Try Windows Azure free for 90 days Click Here http://p.sf.net/sfu/sfd2d-msazure _______________________________________________ Joda-interest mailing list Joda-interest@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/joda-interest