Skip to content

Calendar storage/retrieval is flawed; timezone not stored so fails with daylight saving time #6

@andyjefferson

Description

@andyjefferson

If a user class has a Calendar field and they create the value while running in UK daylight saving time (BST), this is then stored (as GenerlizedTime). They retrieve the object and it is instantiated in GMT not BST.

An example
Calendar=java.util.GregorianCalendar[time=?,areFieldsSet=false,areAllFieldsSet
=true,lenient=true,zone=sun.util.calendar.ZoneInfo[id="Europe/Isle_of_Man",offset=0,dstSavings=3600000,useDaylight=true,transitions=242,lastRule=java.util.SimpleTimeZone[id=Europe/Isle_of_Man,offset=0,dstSavings=3600000,useDaylight=true,startYear=0,startMode=2,startMonth=2,startDay=-1,startDayOfWeek=1,startTime=3600000,startTimeMode=2,endMode=2,endMonth=9,endDay=-1,endDayOfWeek=1,endTime=3600000,endTimeMode=2]],firstDayOfWeek=2,minimalDaysInFirstWeek=4,ERA=1,YEAR=2012,MONTH=4,WEEK_OF_YEAR=20,WEEK_OF_MONTH=3,DAY_OF_MONTH=16,DAY_OF_YEAR=137,DAY_OF_WEEK=4,DAY_OF_WEEK_IN_MONTH=3,AM_PM=0,HOUR=11,HOUR_OF_DAY=11,MINUTE=29,SECOND=23,MILLISECOND=0,ZONE_OFFSET=0,DST_OFFSET=3600000]
Stored as generlized time=19700929114620Z

This is then retrieved as generalized time=20120516112923Z
Calendar=java.util.GregorianCalendar[time=?,areFieldsSet=false,areAllFieldsSet=true,lenient=true,zone=sun.util.calendar.ZoneInfo[id="GMT",offset=0,dstSavings=0,useDaylight=false,transitions=0,lastRule=null],firstDayOfWeek=2,minimalDaysInFirstWeek=4,ERA=1,YEAR=2012,MONTH=4,WEEK_OF_YEAR=20,WEEK_OF_MONTH=3,DAY_OF_MONTH=16,DAY_OF_YEAR=137,DAY_OF_WEEK=4,DAY_OF_WEEK_IN_MONTH=3,AM_PM=0,HOUR=11,HOUR_OF_DAY=11,MINUTE=29,SECOND=23,MILLISECOND=0,ZONE_OFFSET=0,DST_OFFSET=0]

The Calendar TypeConverter stored in datanucleus-core ought to do a better job since it does store timezone code in the string.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions