Menu ▾ ▴

#15 DateTimeField is wired to GMT TimeZone

Next_Release
open
None
5
2009-03-17
2009-01-25
No

I have a database with some Datetime fields, when I display them in BeanGrid or BeanTable, the hour part is different from local time as much as the local time is different from GMT. I need the displayed datetimes to be the same as seen in the database.
I've made a copy of DateTimeField in my project, replaced TimeZone.getTimeZone("GMT") to TimeZone.getDefault() and now when specifying that class as the field type for a property, the hour part of the Datetimes is correct.
I think there are valid use cases where you want the datetimes in your database to be interpreted as local time, not GMT. I'm not sure whether it's better to have one single class to handle both cases or a different class is needed.
I attach a trivial patch that replaces every reference to TimeZone.getTimeZone("GMT") into TimeZone.getDefault(). But I don't pretend this to be a complete solution, and I guess the whole issue needs some more thinking.

Discussion

  • Daniel Toffetti

    Daniel Toffetti - 2009-01-25

    DateTimeField patch

     
  • Dan Syrstad

    Dan Syrstad - 2009-03-16

    I think that GMT was intentional. I think the actual time displayed can be controlled by the DateTimeFormat field.

     
  • Dan Syrstad

    Dan Syrstad - 2009-03-17

    The date should be stored as GMT, but presented in the user's TZ, unless a Calendar is being used. This is because Date is defined as GMT and stores no TZ info.

    However, there is a problem with date fields that display the TZ -- the TZ initially displays correctly (CDT in my case), but after selecting a new date, the TZ changes to GMT - even though the time hasn't changed.

     
  • Dan Syrstad

    Dan Syrstad - 2009-03-17
    • assigned_to: nobody --> dsyrstad
     
  • Dan Syrstad

    Dan Syrstad - 2009-03-17
    • milestone: --> Next_Release
     

Log in to post a comment.