test/jdk/java/time/test/java/time/TestZonedDateTime.java
changeset 57733 be8c11fc16bb
parent 47216 71c04702a3d5
--- a/test/jdk/java/time/test/java/time/TestZonedDateTime.java	Tue Aug 13 13:01:41 2019 -0400
+++ b/test/jdk/java/time/test/java/time/TestZonedDateTime.java	Tue Aug 13 10:10:42 2019 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2019, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -59,12 +59,19 @@
  */
 package test.java.time;
 
+import static org.testng.Assert.assertEquals;
+
+import java.time.Duration;
+import java.time.LocalDateTime;
 import java.time.ZonedDateTime;
+import java.time.ZoneId;
 
 import org.testng.annotations.Test;
 
 /**
  * Test ZonedDateTime.
+ *
+ * @bug 8211990
  */
 @Test
 public class TestZonedDateTime extends AbstractTest {
@@ -74,4 +81,14 @@
         assertImmutable(ZonedDateTime.class);
     }
 
+    @Test
+    public void test_duration() {
+        ZoneId tokyo = ZoneId.of("Asia/Tokyo");
+        ZoneId sanJose = ZoneId.of("America/Los_Angeles");
+
+        ZonedDateTime end = ZonedDateTime.of(LocalDateTime.MAX, sanJose);
+        ZonedDateTime start = end.withZoneSameLocal(tokyo);
+
+        assertEquals(Duration.between(start, end), Duration.ofHours(17));
+    }
 }