Oops I didn't notice that the message had been approved by the moderator... Sorry for having send it twice!!!
Cheers, Amit On Sep 15, 12:10 am, "Amit Dhingra" <[EMAIL PROTECTED]> wrote: > Hi, > I have JSON SQL DateTime objects, which I wish to convert to > java.util.Date objects, for which I have coded as below... (I am using > com.google.gwt.i18n.client.DateTimeFormat.parse for conversion) > > if (...) { > . > . > . > System.out.println(sDate); //sDate is derived from a JSON obj > System.out.println(eDate); //eDate is derived from a JSON obj > > Date stDate = DateTimeFormat.getFormat("yyyy-MM-dd > HH:MM:SS").parse(sDate); > Date endDate = DateTimeFormat.getFormat("yyyy-MM-dd > HH:MM:SS").parse(eDate); > > System.out.println(sDate + " & " + eDate + " Converted Dates are " + > stDate.toString() + " & " + endDate.toString()); > . > . > . > > } > > The code above gives the following output on the console > > 2008-09-01 10:00:00 > 2008-09-01 10:30:00 > 2008-09-01 10:00:00 & 2008-09-01 10:30:00 Converted Dates are Mon Sep > 01 10:00:00 IST 2008 & Tue Jun 01 10:00:00 IST 2010 > 2008-09-01 10:30:00 > 2008-09-01 11:00:00 > 2008-09-01 10:30:00 & 2008-09-01 11:00:00 Converted Dates are Tue Jun > 01 10:00:00 IST 2010 & Mon Sep 01 11:00:00 IST 2008 > 2008-09-03 10:00:00 > 2008-09-03 10:30:30 > 2008-09-03 10:00:00 & 2008-09-03 10:30:30 Converted Dates are Wed Sep > 03 10:00:00 IST 2008 & Thu Jun 03 10:00:00 IST 2010 > 2008-09-04 10:00:00 > 2008-09-04 10:30:00 > 2008-09-04 10:00:00 & 2008-09-04 10:30:00 Converted Dates are Thu Sep > 04 10:00:00 IST 2008 & Fri Jun 04 10:00:00 IST 2010 > > Here I am correctly receiving the JSON object, but while converting it > into the java object using > DateTimeFormat.getFormat("yyyy-MM-dd HH:MM:SS").parse > I get wrong results, e.g. > here > 2008-09-01 10:00:00 > 2008-09-01 10:30:00 > 2008-09-01 10:00:00 & 2008-09-01 10:30:00 Converted Dates are Mon Sep > 01 10:00:00 IST 2008 & Tue Jun 01 10:00:00 IST 2010 > > The converted date is Tue Jun 01 10:00:00 IST 2010 which is incorrect. > > And I see that it is just the second date which is every time wrong!!! > > Am not able to get hold of the flaw here. > Where I might be going wrong??? > > Thanks in advance. > > Thanks & Regards, > Amit --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group. To post to this group, send email to Google-Web-Toolkit@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/Google-Web-Toolkit?hl=en -~----------~----~----~----~------~----~------~--~---