I think this highly depends on the timestamp. I have a dataset
representing CO2 measurements in ice cores going back 650,000 years.
If you simply represent this using doubles, it fails at around 270,000
years (more specifically, date.setYear(-271820) is the last legal
value), because in milliseconds that would exceed 53 bits of
resolution. The Javascript Data object actually performs this check,
and will reject a setYear() which would cause double precision to be
exceeded. (a shame, because clever use of the exponent could allow
very large ranges to be represented, as long as you didn't care about
sub-millisecond significant digits, which is ok in most cases, since
human's couldn't measure to that accuracy until very recently)
If you've got milliseconds as integral numbers in a JSON field, it
should just work using the obvious mechanisms. My Chronoscope charting
library consumes large JSON datasets (30,000+ millisecond timestamp
values)
e.g.
public class MyJSON extends JavaScriptObject {
public final native double getTimestampMillis() /*-{
return this.timestamp;
}-*/;
public final Timestamp getTimestamp() /*-{
return new Date(this.timestamp);
}-*/;
}
public class Timestamp extends JavaScriptObject {
// add JSO methods to getYear/getHour/getMonth/getMinute/getSeconds/etc
}
-Ray
On Fri, Aug 29, 2008 at 12:05 AM, Reinier Zwitserloot
<[EMAIL PROTECTED]> wrote:
>
> I'm moving my projects to GWT 1.5. Long overdue, and something I need
> to get used to anyway to build that JSON improvement I mentioned.
>
> I don't use GWT-Serialization to talk to my server. The server sends
> timestamps as milliseconds. I'd like to turn these milliseconds into
> javascript Date objects.
>
> How do I accomplish this?
>
> As I mentioned when long emulation was on the table, timestamps are
> one of those numbers which are not representable with ints, but they
> fit perfectly in the range where doubles still represent integral
> numbers without loss of precision.
>
> >
>
--~--~---------~--~----~------------~-------~--~----~
http://groups.google.com/group/Google-Web-Toolkit-Contributors
-~----------~----~----~----~------~----~------~--~---