test/jdk/java/time/test/java/time/TestOffsetDateTime.java
changeset 57733 be8c11fc16bb
parent 47216 71c04702a3d5
equal deleted inserted replaced
57732:23e13076e102 57733:be8c11fc16bb
     1 /*
     1 /*
     2  * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2012, 2019, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.
     7  * published by the Free Software Foundation.
    58  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    58  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    59  */
    59  */
    60 package test.java.time;
    60 package test.java.time;
    61 
    61 
    62 import static org.testng.Assert.assertSame;
    62 import static org.testng.Assert.assertSame;
    63 
    63 import static org.testng.Assert.assertEquals;
       
    64 
       
    65 import java.time.Duration;
    64 import java.time.LocalDate;
    66 import java.time.LocalDate;
    65 import java.time.LocalDateTime;
    67 import java.time.LocalDateTime;
    66 import java.time.LocalTime;
    68 import java.time.LocalTime;
    67 import java.time.OffsetDateTime;
    69 import java.time.OffsetDateTime;
    68 import java.time.ZoneOffset;
    70 import java.time.ZoneOffset;
    71 import org.testng.annotations.DataProvider;
    73 import org.testng.annotations.DataProvider;
    72 import org.testng.annotations.Test;
    74 import org.testng.annotations.Test;
    73 
    75 
    74 /**
    76 /**
    75  * Test OffsetDateTime.
    77  * Test OffsetDateTime.
       
    78  *
       
    79  * @bug 8211990
    76  */
    80  */
    77 @Test
    81 @Test
    78 public class TestOffsetDateTime extends AbstractTest {
    82 public class TestOffsetDateTime extends AbstractTest {
    79 
    83 
    80     private static final ZoneOffset OFFSET_PONE = ZoneOffset.ofHours(1);
    84     private static final ZoneOffset OFFSET_PONE = ZoneOffset.ofHours(1);
   318         OffsetDateTime base = OffsetDateTime.of(LocalDate.of(2008, 6, 30), LocalTime.of(11, 30, 59), OFFSET_PONE);
   322         OffsetDateTime base = OffsetDateTime.of(LocalDate.of(2008, 6, 30), LocalTime.of(11, 30, 59), OFFSET_PONE);
   319         OffsetDateTime test = base.minusNanos(0);
   323         OffsetDateTime test = base.minusNanos(0);
   320         assertSame(test, base);
   324         assertSame(test, base);
   321     }
   325     }
   322 
   326 
       
   327     @Test
       
   328     public void test_duration() {
       
   329         OffsetDateTime start = OffsetDateTime.MAX
       
   330                                 .withOffsetSameLocal(ZoneOffset.ofHours(-17));
       
   331         OffsetDateTime end = OffsetDateTime.MAX;
       
   332         assertEquals(Duration.between(start, end), Duration.ofHours(1));
       
   333     }
   323 }
   334 }