JDK-6645292 : [Fmt-Da] Timezone Western Summer Time (Australia) is parsed incorrectly
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.text
  • Affected Version: 1.4.2,5.0
  • Priority: P2
  • Status: Closed
  • Resolution: Fixed
  • OS: solaris,windows_xp
  • CPU: generic,x86
  • Submitted: 2007-12-25
  • Updated: 2011-03-08
  • Resolved: 2011-03-08
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other Other Other Other JDK 6 JDK 7
1.4.2_18-revFixed 1.4.2_19Fixed 5.0u20-revFixed 5.0u21Fixed 6u10Fixed 7 b38Fixed
Description
FULL PRODUCT VERSION :
j2re1.4.2_13

ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows XP [Version 5.1.2600]

A DESCRIPTION OF THE PROBLEM :
After introduction of Daylight Savings Time in Western Australia, I used the Timezone Updater Tool to update the timezones. I got incorrect results parsing and formatting times in this timezone.

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. Run the Timezone Updater Tool to make sure the latest timezones are available
2. Run Test code below for timezones Australia/Perth and compare running it for Australia/Melbourne

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Output:
Success
ACTUAL -
Output:
20071112020000 Coordinated Universal Time -> 20071112110000 Western Summer Time (Australia) in DST
20071112030000 Coordinated Universal Time
since epoch before: 1194832800000 since epoch after 1194836400000

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
public void testSimple()
	{
		TimeZone tz = TimeZone.getTimeZone("Australia/Perth");
		//TimeZone tz = TimeZone.getTimeZone("Australia/Melbourne");
		TimeZone utcTZ = TimeZone.getTimeZone("UTC");
		SimpleDateFormat f = new SimpleDateFormat("yyyyMMddHHmmss zzzz");
		f.setTimeZone(tz);
		String time = "20071112020000 Coordinated Universal Time";
		SimpleDateFormat utcFormatter = new SimpleDateFormat("yyyyMMddHHmmss zzzz");
		utcFormatter.setTimeZone(TimeZone.getTimeZone("UTC"));
		String output;
		Date date;
		String dateS;
		boolean inDST;
		long sinceEpoch1;
		long sinceEpoch2;
		try {
			output = time;
			date = utcFormatter.parse(time);
			sinceEpoch1 = date.getTime();
			dateS = f.format(date);
			output += " -> " + dateS;
			inDST = tz.inDaylightTime(date);
			if (!inDST) {
				output += " not";
			}
			output +=" in DST";
			date = f.parse(dateS);
			sinceEpoch2 = date.getTime();
			f.setTimeZone(utcTZ);
			dateS = utcFormatter.format(date);
			output += "\n" + dateS;
			if (!dateS.equals(time)) {
				output += "\nsince epoch before: " +
					sinceEpoch1 + " since epoch after " +
					sinceEpoch2;
				System.out.println(output);
			} else {
				System.out.println("Success");
			}
		} catch (ParseException e) {
			e.printStackTrace(System.err);
		}
	}
---------- END SOURCE ----------

CUSTOMER SUBMITTED WORKAROUND :
Have not found a workaround.

Comments
EVALUATION SimpleDateFormat.parse() calls TimeZone.getDSTSavings() to get the daylight saving time amount to let a Calendar calculate the given local time. However, TimeZone.getDSTSavings() returns 0 for Australia/Perth because its last DST rule doesn't observe daylight saving time (it's a 3-year trial for observing DST). We could let the Calendar calculate the local time from the given TimeZone object. However, this change will involve some incompatible changes in other time zones.
25-12-2007