|
Quick Lists
|
|
Bug ID:
|
6645292
|
|
Votes
|
3
|
|
Synopsis
|
[Fmt-Da] Timezone Western Summer Time (Australia) is parsed incorrectly
|
|
Category
|
java:classes_text
|
|
Reported Against
|
|
|
Release Fixed
|
7(b38),
6u10(b26) (Bug ID:2161972)
|
|
State
|
10-Fix Delivered,
bug
|
|
Priority:
|
2-High
|
|
Related Bugs
|
|
|
Submit Date
|
25-DEC-2007
|
|
Description
|
FULL PRODUCT VERSION :
j2re1.4.2_13
ADDITIONAL OS VERSION INFORMATION :
customer 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.
Posted Date : 2007-12-25 05:39:03.0
|
|
Work Around
|
N/A
|
|
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.
Posted Date : 2007-12-25 07:47:37.0
|
|
Comments
|
PLEASE NOTE: JDK6 is formerly known as Project Mustang
|
|
|
 |