Thanks, that worked great!
On Mar 11, 2:45 am, Tony Strauss <[email protected]>
wrote:
> If millisecond precision is adequate for your application, you can use
> java.util.Date. Your code with java.util.Date might look something
> like this:
>
> //Format the timestamp
> DateTimeFormat timestampParser = DateTimeFormat.getFormat
> ("yyyy-MM-dd HH:mm:ss.SSS");
> Date newOrderTimeStamp = timestampParser.parse("2009-03-10
> 22:30:29.000");
> DateTimeFormat timeFormat = DateTimeFormat.getShortTimeFormat
> ();
> Label newOrderTimeStampLabel = new Label(timeFormat.format
> (newOrderTimeStamp) + " ");
>
> //Calculated minutes passed since order submitted
> Date currentTimeStamp = new Date();
> long currentTime = currentTimeStamp.getTime();
> long tsTime = newOrderTimeStamp.getTime();
> long calculatedTime = currentTime - tsTime;
> long minutesSinceOrderSubmittedLong = (calculatedTime /
> 1000) / 60;
> Label minutesSinceOrderSubmittedLabel = new Label
> (minutesSinceOrderSubmittedLong + " minutes ago");
>
> Be careful if you need to do this kind of calculation frequently,
> however. Javascript does not support longs natively, and so GWT ( >
> 1.5) emulates longs with two integers. While this emulation is
> correct, it also is slow. If performance is a concern with this code,
> you may want to consider using doubles for the calculation instead.
>
> Tony
>
> On Mar 10, 6:15 pm, "[email protected]"
>
> <[email protected]> wrote:
> > Hi,
>
> > I seem to be having an issue with timestamps when my project is
> > compiled (It works fine in Hosted mode). I know why, im just wondering
> > if anyone could tell me a quick way around my problem. So heres my
> > code on the client:
>
> > //Format the timestamp
> > Timestamp newOrderTimeStamp =
> > Timestamp.valueOf
> > (data.newOrderTimeStampArrayList.get(i).toString());
> > //System.out.println("newOrderTimeStamp: "
> > + newOrderTimeStamp);
> > DateTimeFormat timeFormat =
> > DateTimeFormat.getShortTimeFormat();
> > Label newOrderTimeStampLabel = new
> > Label(timeFormat.format
> > (newOrderTimeStamp) + " ");
>
> > //Calculated minutes passed since order
> > submitted
> > long currentTime = currentTimeStamp.getTime();
> > long tsTime = newOrderTimeStamp.getTime();
> > long calculatedTime = currentTime - tsTime;
> > long minutesSinceOrderSubmittedLong =
> > (calculatedTime / 1000) /
> > 60;
> > Label minutesSinceOrderSubmittedLabel = new
> > Label
> > (minutesSinceOrderSubmittedLong + " minutes ago");
>
> > So basically it seems that Timestamp which is of type
> > java.sql.Timestamp works fine in hosted mode, but when compiled does
> > not work. Is there a GWT equivalent to java.sql.Timestamp??
>
> > Or does anyone have any other suggestions on how to use timestamps on
> > the client?
>
> > Regards,
> > Jack
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Google Web Toolkit" group.
To post to this group, send email to [email protected]
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
-~----------~----~----~----~------~----~------~--~---