tags:

views:

116

answers:

2

hi there, Can any one explain how Java SimpleTimeZone rules are interpreted. For example a rule for Europe/London is as follows:

var rule = {
    "dstSavings": 3600000,
    "startYear": 0,
    "startMonth": 2,
    "startDay": -1,
    "startDayOfWeek": 1,
    "endMonth": 9,
    "endDay": -1,
    "endDayOfWeek": 1,
    "endTime": 3600000,
    "rawOffset": 0,
    "startTime": 3600000,
    "startTimeMode": "UTC",
    "endTimeMode": "UTC",
    "useDaylight": true
  };

Reading the STZ documentation is helpful but not for this particular rule.

What does endDay = 0 signify? What if startDay = 0?

thanks,

A: 

endDay and startDay indicate the end and start of Daylight Saving Time. As this is always in the night from saturday till sunday. When describing DST this indicated the 'startDay'th Sunday of the month. In this case I'm not entirely sure what -1 means. In linux timezones a 5 indicates the last day of the month, so maybe here that is -1.

Thirler
+2  A: 

In the API (same link you provided in the question), the constructor documentation says:

"startDay - The day of the month on which the daylight saving time starts. See the class description for the special cases of this parameter."
"endDay - The day of the month on which the daylight saving time ends. See the class description for the special cases of this parameter."

Could you be more specific about what's confusing?

EDIT:

Okay, I better understand your question now. As you have figured out for yourself, a positive number means "count forwards" and a negative number means "count backwards." Zero appears to indicate that there is no daylight savings active in that location.

EDIT 2:

Per the source, "a value of 0 is illegal." See lines 984 and 1045. This appears to be okay, if useDaylight is false, though that is not the case in your sample JSON.

Lord Torgamus
LT, what I am confused about is the startDay = 0 or endDay = 0 case. The documentation explains clearly on positive and negative cases but doesnt explain ZERO. thanks
bushman
LT, you are right!!!! it is -- my serializer java -> json was taking a default value of 0. stupid mistake from my side. Thank you for teaching me how another way of debugging. Thumbs up!
bushman