FULL PRODUCT VERSION :
java version " 1.6.0_33 "
Java(TM) SE Runtime Environment (build 1.6.0_33-b03)
Java HotSpot(TM) 64-Bit Server VM (build 20.8-b03, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows [Version 6.1.7601]
A DESCRIPTION OF THE PROBLEM :
When formatting dates through java.util.Formatter, different results are obtained for time zone in CEST when formatting as %tz and %tZ.
The following code:
java.util.Date d = new java.util.Date();
System.out.println(d);
System.out.format( " %1$tF T %1$tT %1$tz %n " , d);
System.out.format( " %1$tF T %1$tT %1$tZ %n%n " , d);
java.util.Formatter f = new java.util.Formatter(System.out);
f.format( " %1$tF T %1$tT %1$tz %n " , d);
f.format( " %1$tF T %1$tT %1$tZ %n%n " , d);
System.out.println(String.format( " %1$tF T %1$tT %1$tz " , d));
System.out.println(String.format( " %1$tF T %1$tT %1$tZ %n " , d));
Results in:
Tue Oct 09 17:36:52 CEST 2012
2012-10-09 T 17:36:52 +0100
2012-10-09 T 17:36:52 CEST
2012-10-09 T 17:36:52 +0100
2012-10-09 T 17:36:52 CEST
2012-10-09 T 17:36:52 +0100
2012-10-09 T 17:36:52 CEST
The offsets +01:00 are wrong for CEST time zone which is +02:00.
I think this is a bug. Wikipedia mentiones ISO 8601 (http://en.wikipedia.org/wiki/ISO_8601#Time_offsets_from_UTC) where it says that numerical offsets account for DST differences.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Tue Oct 09 17:36:52 CEST 2012
2012-10-09 T 17:36:52 +0200
2012-10-09 T 17:36:52 CEST
2012-10-09 T 17:36:52 +0200
2012-10-09 T 17:36:52 CEST
2012-10-09 T 17:36:52 +0200
2012-10-09 T 17:36:52 CEST
ACTUAL -
Tue Oct 09 17:36:52 CEST 2012
2012-10-09 T 17:36:52 +0100
2012-10-09 T 17:36:52 CEST
2012-10-09 T 17:36:52 +0100
2012-10-09 T 17:36:52 CEST
2012-10-09 T 17:36:52 +0100
2012-10-09 T 17:36:52 CEST
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
java.util.Date d = new java.util.Date();
System.out.println(d);
System.out.format( " %1$tF T %1$tT %1$tz %n " , d);
System.out.format( " %1$tF T %1$tT %1$tZ %n%n " , d);
java.util.Formatter f = new java.util.Formatter(System.out);
f.format( " %1$tF T %1$tT %1$tz %n " , d);
f.format( " %1$tF T %1$tT %1$tZ %n%n " , d);
System.out.println(String.format( " %1$tF T %1$tT %1$tz " , d));
System.out.println(String.format( " %1$tF T %1$tT %1$tZ %n " , d));
---------- END SOURCE ----------
java version " 1.6.0_33 "
Java(TM) SE Runtime Environment (build 1.6.0_33-b03)
Java HotSpot(TM) 64-Bit Server VM (build 20.8-b03, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows [Version 6.1.7601]
A DESCRIPTION OF THE PROBLEM :
When formatting dates through java.util.Formatter, different results are obtained for time zone in CEST when formatting as %tz and %tZ.
The following code:
java.util.Date d = new java.util.Date();
System.out.println(d);
System.out.format( " %1$tF T %1$tT %1$tz %n " , d);
System.out.format( " %1$tF T %1$tT %1$tZ %n%n " , d);
java.util.Formatter f = new java.util.Formatter(System.out);
f.format( " %1$tF T %1$tT %1$tz %n " , d);
f.format( " %1$tF T %1$tT %1$tZ %n%n " , d);
System.out.println(String.format( " %1$tF T %1$tT %1$tz " , d));
System.out.println(String.format( " %1$tF T %1$tT %1$tZ %n " , d));
Results in:
Tue Oct 09 17:36:52 CEST 2012
2012-10-09 T 17:36:52 +0100
2012-10-09 T 17:36:52 CEST
2012-10-09 T 17:36:52 +0100
2012-10-09 T 17:36:52 CEST
2012-10-09 T 17:36:52 +0100
2012-10-09 T 17:36:52 CEST
The offsets +01:00 are wrong for CEST time zone which is +02:00.
I think this is a bug. Wikipedia mentiones ISO 8601 (http://en.wikipedia.org/wiki/ISO_8601#Time_offsets_from_UTC) where it says that numerical offsets account for DST differences.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Tue Oct 09 17:36:52 CEST 2012
2012-10-09 T 17:36:52 +0200
2012-10-09 T 17:36:52 CEST
2012-10-09 T 17:36:52 +0200
2012-10-09 T 17:36:52 CEST
2012-10-09 T 17:36:52 +0200
2012-10-09 T 17:36:52 CEST
ACTUAL -
Tue Oct 09 17:36:52 CEST 2012
2012-10-09 T 17:36:52 +0100
2012-10-09 T 17:36:52 CEST
2012-10-09 T 17:36:52 +0100
2012-10-09 T 17:36:52 CEST
2012-10-09 T 17:36:52 +0100
2012-10-09 T 17:36:52 CEST
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
java.util.Date d = new java.util.Date();
System.out.println(d);
System.out.format( " %1$tF T %1$tT %1$tz %n " , d);
System.out.format( " %1$tF T %1$tT %1$tZ %n%n " , d);
java.util.Formatter f = new java.util.Formatter(System.out);
f.format( " %1$tF T %1$tT %1$tz %n " , d);
f.format( " %1$tF T %1$tT %1$tZ %n%n " , d);
System.out.println(String.format( " %1$tF T %1$tT %1$tz " , d));
System.out.println(String.format( " %1$tF T %1$tT %1$tZ %n " , d));
---------- END SOURCE ----------