posted 10 years ago
I found an issue in code that GregorianCalendar with negative time and ERA as BC as below.
java.util.GregorianCalendar[time=-125520479618000,areFieldsSet=true,areAllFieldsSet=true,lenient=true,zone=sun.util.calendar.ZoneInfo[id="GMT",offset=0,dstSavings=0,useDaylight=false,transitions=0,lastRule=null],firstDayOfWeek=1,minimalDaysInFirstWeek=1,ERA=0,YEAR=2009,MONTH=5,WEEK_OF_YEAR=25,WEEK_OF_MONTH=4,DAY_OF_MONTH=17,DAY_OF_YEAR=169,DAY_OF_WEEK=1,DAY_OF_WEEK_IN_MONTH=3,AM_PM=1,HOUR=4,HOUR_OF_DAY=16,MINUTE=6,SECOND=22,MILLISECOND=0,ZONE_OFFSET=0,DST_OFFSET=0]
notice
time=-125520479618000,
ERA=0
It is only happened for the certain date, most other time and calendar are correct.
Good calenda
java.util.GregorianCalendar[time=1186393080000,areFieldsSet=true,areAllFieldsSet=true,lenient=true,zone=sun.util.calendar.ZoneInfo[id="GMT",offset=0,dstSavings=0,useDaylight=false,transitions=0,lastRule=null],firstDayOfWeek=1,minimalDaysInFirstWeek=1,ERA=1,YEAR=2007,MONTH=7,WEEK_OF_YEAR=32,WEEK_OF_MONTH=2,DAY_OF_MONTH=6,DAY_OF_YEAR=218,DAY_OF_WEEK=2,DAY_OF_WEEK_IN_MONTH=1,AM_PM=0,HOUR=9,HOUR_OF_DAY=9,MINUTE=38,SECOND=0,MILLISECOND=0,ZONE_OFFSET=0,DST_OFFSET=0]
here
time=118639308000
ERA=1
Is there any case the GregorianCalendar could get the negative time ? Any suggestions are appreciated!