test/java/time/test/java/time/TestOffsetDateTime_instants.java

Print this page




  42  *    and/or other materials provided with the distribution.
  43  *
  44  *  * Neither the name of JSR-310 nor the names of its contributors
  45  *    may be used to endorse or promote products derived from this software
  46  *    without specific prior written permission.
  47  *
  48  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  49  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  50  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  51  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
  52  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
  53  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  54  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  55  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  56  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  57  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  58  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  59  */
  60 package test.java.time;
  61 


  62 import java.time.DateTimeException;
  63 import java.time.Instant;
  64 import java.time.LocalDate;
  65 import java.time.LocalTime;
  66 import java.time.Month;
  67 import java.time.ZoneOffset;
  68 
  69 import java.time.OffsetDateTime;
  70 import java.time.Year;
  71 
  72 import static org.testng.Assert.assertEquals;
  73 
  74 import org.testng.annotations.Test;
  75 
  76 /**
  77  * Test OffsetDateTime creation.
  78  */
  79 @Test
  80 public class TestOffsetDateTime_instants {
  81 
  82     private static final ZoneOffset OFFSET_PONE = ZoneOffset.ofHours(1);
  83     private static final ZoneOffset OFFSET_MAX = ZoneOffset.ofHours(18);
  84     private static final ZoneOffset OFFSET_MIN = ZoneOffset.ofHours(-18);
  85 
  86     //-----------------------------------------------------------------------
  87     @Test(expectedExceptions=NullPointerException.class)
  88     public void factory_ofInstant_nullInstant() {
  89         OffsetDateTime.ofInstant((Instant) null, OFFSET_PONE);
  90     }
  91 
  92     @Test(expectedExceptions=NullPointerException.class)




  42  *    and/or other materials provided with the distribution.
  43  *
  44  *  * Neither the name of JSR-310 nor the names of its contributors
  45  *    may be used to endorse or promote products derived from this software
  46  *    without specific prior written permission.
  47  *
  48  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  49  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  50  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  51  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
  52  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
  53  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  54  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  55  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  56  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  57  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  58  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  59  */
  60 package test.java.time;
  61 
  62 import static org.testng.Assert.assertEquals;
  63 
  64 import java.time.DateTimeException;
  65 import java.time.Instant;
  66 import java.time.LocalDate;
  67 import java.time.LocalTime;
  68 import java.time.Month;


  69 import java.time.OffsetDateTime;
  70 import java.time.Year;
  71 import java.time.ZoneOffset;

  72 
  73 import org.testng.annotations.Test;
  74 
  75 /**
  76  * Test OffsetDateTime creation.
  77  */
  78 @Test
  79 public class TestOffsetDateTime_instants {
  80 
  81     private static final ZoneOffset OFFSET_PONE = ZoneOffset.ofHours(1);
  82     private static final ZoneOffset OFFSET_MAX = ZoneOffset.ofHours(18);
  83     private static final ZoneOffset OFFSET_MIN = ZoneOffset.ofHours(-18);
  84 
  85     //-----------------------------------------------------------------------
  86     @Test(expectedExceptions=NullPointerException.class)
  87     public void factory_ofInstant_nullInstant() {
  88         OffsetDateTime.ofInstant((Instant) null, OFFSET_PONE);
  89     }
  90 
  91     @Test(expectedExceptions=NullPointerException.class)