JDK-8136740 : ZonedDateTime - parsing an date time string on a daylight saving boundary
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.time
  • Affected Version: 8u51
  • Priority: P4
  • Status: Resolved
  • Resolution: Duplicate
  • OS: windows_8
  • CPU: x86
  • Submitted: 2015-07-20
  • Updated: 2015-11-24
  • Resolved: 2015-11-24
Related Reports
Relates :  
Description
FULL PRODUCT VERSION :
java version "1.8.0_51"
Java(TM) SE Runtime Environment (build 1.8.0_51-b16)
Java HotSpot(TM) 64-Bit Server VM (build 25.51-b03, mixed mode)

ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows [Version 6.3.9600]

A DESCRIPTION OF THE PROBLEM :
//parsing the date time string on a daylight saving boundary
ZonedDateTime dt = ZonedDateTime.parse("2015-10-25T02:00:00+01:00[Europe/Berlin]");
System.out.println(dt);
// result in             2015-10-25T02:00+02:00[Europe/Berlin]
// but ist must be 2015-10-25T02:00+01:00[Europe/Berlin]

parsing the string '2015-10-25T01:00:00+02:00[Europe/Berlin]' will result a correct value

ADDITIONAL REGRESSION INFORMATION: 
java version "1.8.0_51"
Java(TM) SE Runtime Environment (build 1.8.0_51-b16)
Java HotSpot(TM) 64-Bit Server VM (build 25.51-b03, mixed mode)

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
see description

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
2015-10-25T02:00+01:00[Europe/Berlin]
ACTUAL -
2015-10-25T02:00+02:00[Europe/Berlin]

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
	@Test
	public void test()
	{
		ZonedDateTime dt = ZonedDateTime.parse("2015-10-25T01:00:00+02:00[Europe/Berlin]");
		dt = dt.plusMinutes(120);
		ZonedDateTime dt2 = ZonedDateTime.parse(dt.format(DateTimeFormatter.ISO_DATE_TIME),
			DateTimeFormatter.ISO_DATE_TIME);
		System.out.println("1: " + dt.format(DateTimeFormatter.ISO_DATE_TIME) + " " + dt.toEpochSecond());
		System.out.println("2: " + dt2.format(DateTimeFormatter.ISO_DATE_TIME) + " " + dt2.toEpochSecond());
		System.out.println();
		dt = dt.plusMinutes(30);
		dt2 = ZonedDateTime.parse(dt.format(DateTimeFormatter.ISO_DATE_TIME), DateTimeFormatter.ISO_DATE_TIME);
		System.out.println("1: " + dt.format(DateTimeFormatter.ISO_DATE_TIME) + " " + dt.toEpochSecond());
		System.out.println("2: " + dt2.format(DateTimeFormatter.ISO_DATE_TIME) + " " + dt2.toEpochSecond());
		System.out.println();
		dt = dt.plusMinutes(30);
		dt2 = ZonedDateTime.parse(dt.format(DateTimeFormatter.ISO_DATE_TIME), DateTimeFormatter.ISO_DATE_TIME);
		System.out.println("1: " + dt.format(DateTimeFormatter.ISO_DATE_TIME) + " " + dt.toEpochSecond());
		System.out.println("2: " + dt2.format(DateTimeFormatter.ISO_DATE_TIME) + " " + dt2.toEpochSecond());
		System.out.println();
	}

---------- END SOURCE ----------


Comments
This is a duplicate of JDK-8066982 which has a more complete description of the cause and way to address it.
24-11-2015

This is a duplicate of JDK-8066982
24-11-2015

I had reviewed the linked bug and found this to be "Not an Issue". [~aefimov] and [~okutsu], please review if my understanding is correct and both of the issues can be closed as "Not and Issue".
24-11-2015

Run the attached test case (TimeZoneTest.java). - Checked this for JDK 8u60, 8u66 b02 and 9 ea b80 and could reproduce as stated in the actual report. - Output with JDK 8u60: $ java TimeZoneTest.java run: 1: 2015-10-25T02:00:00+01:00[Europe/Berlin] 1445734800 2: 2015-10-25T02:00:00+02:00[Europe/Berlin] 1445731200
18-09-2015