Re: Date Serialization

161 views
Skip to first unread message

Philippe Lhoste

unread,
Jul 3, 2012, 8:42:11 AM7/3/12
to Google-We...@googlegroups.com
On 30/06/2012 16:37, Daniel F. wrote:
> I need to parse serialized *java.util.Date* values in Python. Where can I find information
> on the timestamp that represents date and time in the serialized format?

JavaDoc... http://docs.oracle.com/javase/6/docs/api/java/util/Date.html
See getTime()

--
Philippe Lhoste
-- (near) Paris -- France
-- http://Phi.Lho.free.fr
-- -- -- -- -- -- -- -- -- -- -- -- -- --



Daniel F.

unread,
Jul 3, 2012, 4:41:20 PM7/3/12
to google-we...@googlegroups.com, Google-We...@googlegroups.com

Am Dienstag, 3. Juli 2012 14:42:11 UTC+2 schrieb PhiLho:
On 30/06/2012 16:37, Daniel F. wrote:
> I need to parse serialized *java.util.Date* values in Python. Where can I find information
> on the timestamp that represents date and time in the serialized format?

JavaDoc... http://docs.oracle.com/javase/6/docs/api/java/util/Date.html
See getTime()

This does not seem to be the value which I find in the serialized date. I still have to subtract some "magic value" from it. 

Paul Robinson

unread,
Jul 3, 2012, 5:41:08 PM7/3/12
to google-we...@googlegroups.com
The timezone offset, by any chance?

Paul

Jim Douglas

unread,
Jul 3, 2012, 6:43:30 PM7/3/12
to Google Web Toolkit
Yup, probably the timezone offset. We tripped over that too (wrong
dates when the server and client were in different time zones); we
stopped serializing Date objects and switched to sending a customized
y/m/d value instead.

On Jul 3, 2:41 pm, Paul Robinson <ukcue...@gmail.com> wrote:
> On 03/07/12 21:41, Daniel F. wrote:
>
> > Am Dienstag, 3. Juli 2012 14:42:11 UTC+2 schrieb PhiLho:
>
> >     On 30/06/2012 16:37, Daniel F. wrote:
> >     > I need to parse serialized *java.util.Date* values in Python. Where can I find information
> >     > on the timestamp that represents date and time in the serialized format?
>
> >     JavaDoc...http://docs.oracle.com/javase/6/docs/api/java/util/Date.html<http://docs.oracle.com/javase/6/docs/api/java/util/Date.html>

Thomas Broyer

unread,
Jul 3, 2012, 8:07:15 PM7/3/12
to google-we...@googlegroups.com


On Wednesday, July 4, 2012 12:43:30 AM UTC+2, Jim Douglas wrote:
Yup, probably the timezone offset.  We tripped over that too (wrong
dates when the server and client were in different time zones); we
stopped serializing Date objects and switched to sending a customized
y/m/d value instead.

Aka “using the right tool for the job”.
java.util.Date represents a “specific moment in time” (as an offset from Epoch, and the Y/M/D/H/M/S are computed from there depending on the TZ); if you want a DMY independent from the TZ, then java.util.Date is not “the right tool for the job”. You could use JodaTime's or ThreeTen's LocalDate for instance (they unfortunately don't play well with GWT: existing ports have not been maintained for *years*).

Joseph Lust

unread,
Jul 3, 2012, 9:17:42 PM7/3/12
to google-we...@googlegroups.com
This question comes up so often that it ought to be a priority for GWT 2.6. Perhaps a module setting to for TZ safe date serialization?

See the solution of a custom date serializer in this earlier post



Sincerely,
Joseph

Thomas Broyer

unread,
Jul 3, 2012, 9:32:33 PM7/3/12
to google-we...@googlegroups.com


On Wednesday, July 4, 2012 3:17:42 AM UTC+2, Joseph Lust wrote:
This question comes up so often that it ought to be a priority for GWT 2.6. Perhaps a module setting to for TZ safe date serialization?

If the timezone matters to you, you can simply send it along with the date (timestamp). The fact is a java.util.Date is not enough, as the timezone is the one of the JVM; I bet you'd have the same behavior with Java serialization and/or RMI.

The issue is Java's standard lib, not GWT. JSR 310 aims at fixing it (highly inspired from JodaTime), but is not ready yet (http://threeten.sf.net)

Daniel F.

unread,
Jul 13, 2012, 4:19:10 AM7/13/12
to google-we...@googlegroups.com
Probably not, because the constant offset is currently

1340029810 seconds
which is
15509 days

That would be a strange timezone ;-)

So there is probably a different reason. Or it lies in the internals of the application from which the data comes and to which I have no access.

Daniel

(And sorry for the late answer.)

Paul Robinson

unread,
Jul 13, 2012, 4:42:45 AM7/13/12
to google-we...@googlegroups.com
Curiously, 15509 is pretty close to the number of days since Jan 1, 1970 which is when unix timestamps are measured from.

According to this:
    http://www.convertunits.com/dates/daysfromnow/-15509

15509 days ago was Jan 26, 1970.

That probably won't help you :)

Paul
--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To view this discussion on the web visit https://groups.google.com/d/msg/google-web-toolkit/-/IMLhxemukckJ.
To post to this group, send email to google-we...@googlegroups.com.
To unsubscribe from this group, send email to google-web-tool...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.


Reply all
Reply to author
Forward
0 new messages