1 /*
   2  * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   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
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 /*
  25  * This file is available under and governed by the GNU General Public
  26  * License version 2 only, as published by the Free Software Foundation.
  27  * However, the following notice accompanied the original version of this
  28  * file:
  29  *
  30  * Copyright (c) 2008-2012, Stephen Colebourne & Michael Nascimento Santos
  31  *
  32  * All rights reserved.
  33  *
  34  * Redistribution and use in source and binary forms, with or without
  35  * modification, are permitted provided that the following conditions are met:
  36  *
  37  *  * Redistributions of source code must retain the above copyright notice,
  38  *    this list of conditions and the following disclaimer.
  39  *
  40  *  * Redistributions in binary form must reproduce the above copyright notice,
  41  *    this list of conditions and the following disclaimer in the documentation
  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 tck.java.time;
  61 
  62 import static java.time.temporal.ChronoField.AMPM_OF_DAY;
  63 import static java.time.temporal.ChronoField.CLOCK_HOUR_OF_AMPM;
  64 import static java.time.temporal.ChronoField.CLOCK_HOUR_OF_DAY;
  65 import static java.time.temporal.ChronoField.HOUR_OF_AMPM;
  66 import static java.time.temporal.ChronoField.HOUR_OF_DAY;
  67 import static java.time.temporal.ChronoField.MICRO_OF_DAY;
  68 import static java.time.temporal.ChronoField.MICRO_OF_SECOND;
  69 import static java.time.temporal.ChronoField.MILLI_OF_DAY;
  70 import static java.time.temporal.ChronoField.MILLI_OF_SECOND;
  71 import static java.time.temporal.ChronoField.MINUTE_OF_DAY;
  72 import static java.time.temporal.ChronoField.MINUTE_OF_HOUR;
  73 import static java.time.temporal.ChronoField.NANO_OF_DAY;
  74 import static java.time.temporal.ChronoField.NANO_OF_SECOND;
  75 import static java.time.temporal.ChronoField.OFFSET_SECONDS;
  76 import static java.time.temporal.ChronoField.SECOND_OF_DAY;
  77 import static java.time.temporal.ChronoField.SECOND_OF_MINUTE;
  78 import static java.time.temporal.ChronoUnit.MONTHS;
  79 import static java.time.temporal.ChronoUnit.DAYS;
  80 import static java.time.temporal.ChronoUnit.HOURS;
  81 import static java.time.temporal.ChronoUnit.MINUTES;
  82 import static java.time.temporal.ChronoUnit.MICROS;
  83 import static java.time.temporal.ChronoUnit.MILLIS;
  84 import static java.time.temporal.ChronoUnit.HALF_DAYS;
  85 import static java.time.temporal.ChronoUnit.NANOS;
  86 import static java.time.temporal.ChronoUnit.SECONDS;
  87 import static org.testng.Assert.assertEquals;
  88 import static org.testng.Assert.assertNotNull;
  89 import static org.testng.Assert.assertTrue;
  90 import static org.testng.Assert.fail;
  91 
  92 import java.lang.reflect.Constructor;
  93 import java.lang.reflect.InvocationTargetException;
  94 import java.time.Clock;
  95 import java.time.DateTimeException;
  96 import java.time.Instant;
  97 import java.time.LocalDate;
  98 import java.time.LocalDateTime;
  99 import java.time.LocalTime;
 100 import java.time.OffsetDateTime;
 101 import java.time.OffsetTime;
 102 import java.time.Period;
 103 import java.time.ZoneId;
 104 import java.time.ZoneOffset;
 105 import java.time.ZonedDateTime;
 106 import java.time.format.DateTimeFormatter;
 107 import java.time.format.DateTimeParseException;
 108 import java.time.temporal.ChronoField;
 109 import java.time.temporal.ChronoUnit;
 110 import java.time.temporal.JulianFields;
 111 import java.time.temporal.Temporal;
 112 import java.time.temporal.TemporalAccessor;
 113 import java.time.temporal.TemporalAdjuster;
 114 import java.time.temporal.TemporalAmount;
 115 import java.time.temporal.TemporalField;
 116 import java.time.temporal.TemporalQueries;
 117 import java.time.temporal.TemporalQuery;
 118 import java.time.temporal.TemporalUnit;
 119 import java.util.ArrayList;
 120 import java.util.Arrays;
 121 import java.util.List;
 122 
 123 import org.testng.annotations.BeforeMethod;
 124 import org.testng.annotations.DataProvider;
 125 import org.testng.annotations.Test;
 126 import test.java.time.MockSimplePeriod;
 127 
 128 /**
 129  * Test OffsetTime.
 130  */
 131 @Test
 132 public class TCKOffsetTime extends AbstractDateTimeTest {
 133 
 134     private static final ZoneId ZONE_GAZA = ZoneId.of("Asia/Gaza");
 135     private static final ZoneOffset OFFSET_PONE = ZoneOffset.ofHours(1);
 136     private static final ZoneOffset OFFSET_PTWO = ZoneOffset.ofHours(2);
 137     private static final LocalDate DATE = LocalDate.of(2008, 12, 3);
 138     private OffsetTime TEST_11_30_59_500_PONE;
 139 
 140     @BeforeMethod
 141     public void setUp() {
 142         TEST_11_30_59_500_PONE = OffsetTime.of(11, 30, 59, 500, OFFSET_PONE);
 143     }
 144 
 145     //-----------------------------------------------------------------------
 146     @Override
 147     protected List<TemporalAccessor> samples() {
 148         TemporalAccessor[] array = {TEST_11_30_59_500_PONE, OffsetTime.MIN, OffsetTime.MAX};
 149         return Arrays.asList(array);
 150     }
 151 
 152     @Override
 153     protected List<TemporalField> validFields() {
 154         TemporalField[] array = {
 155             NANO_OF_SECOND,
 156             NANO_OF_DAY,
 157             MICRO_OF_SECOND,
 158             MICRO_OF_DAY,
 159             MILLI_OF_SECOND,
 160             MILLI_OF_DAY,
 161             SECOND_OF_MINUTE,
 162             SECOND_OF_DAY,
 163             MINUTE_OF_HOUR,
 164             MINUTE_OF_DAY,
 165             CLOCK_HOUR_OF_AMPM,
 166             HOUR_OF_AMPM,
 167             CLOCK_HOUR_OF_DAY,
 168             HOUR_OF_DAY,
 169             AMPM_OF_DAY,
 170             OFFSET_SECONDS,
 171         };
 172         return Arrays.asList(array);
 173     }
 174 
 175     @Override
 176     protected List<TemporalField> invalidFields() {
 177         List<TemporalField> list = new ArrayList<>(Arrays.<TemporalField>asList(ChronoField.values()));
 178         list.removeAll(validFields());
 179         list.add(JulianFields.JULIAN_DAY);
 180         list.add(JulianFields.MODIFIED_JULIAN_DAY);
 181         list.add(JulianFields.RATA_DIE);
 182         return list;
 183     }
 184 
 185     //-----------------------------------------------------------------------
 186     // constants
 187     //-----------------------------------------------------------------------
 188     @Test
 189     public void constant_MIN() {
 190         check(OffsetTime.MIN, 0, 0, 0, 0, ZoneOffset.MAX);
 191     }
 192 
 193     @Test
 194     public void constant_MAX() {
 195         check(OffsetTime.MAX, 23, 59, 59, 999999999, ZoneOffset.MIN);
 196     }
 197 
 198     //-----------------------------------------------------------------------
 199     // now()
 200     //-----------------------------------------------------------------------
 201     @Test
 202     public void now() {
 203         final long DELTA = 20_000_000_000L;    // 20 seconds of nanos leeway
 204         ZonedDateTime nowDT = ZonedDateTime.now();
 205 
 206         OffsetTime expected = OffsetTime.now(Clock.systemDefaultZone());
 207         OffsetTime test = OffsetTime.now();
 208         long diff = Math.abs(test.toLocalTime().toNanoOfDay() - expected.toLocalTime().toNanoOfDay());
 209         if (diff >= DELTA) {
 210             // may be date change
 211             expected = OffsetTime.now(Clock.systemDefaultZone());
 212             test = OffsetTime.now();
 213             diff = Math.abs(test.toLocalTime().toNanoOfDay() - expected.toLocalTime().toNanoOfDay());
 214         }
 215         assertTrue(diff < DELTA);
 216         assertEquals(test.getOffset(), nowDT.getOffset());
 217     }
 218 
 219     //-----------------------------------------------------------------------
 220     // now(Clock)
 221     //-----------------------------------------------------------------------
 222     @Test
 223     public void now_Clock_allSecsInDay() {
 224         for (int i = 0; i < (2 * 24 * 60 * 60); i++) {
 225             Instant instant = Instant.ofEpochSecond(i, 8);
 226             Clock clock = Clock.fixed(instant, ZoneOffset.UTC);
 227             OffsetTime test = OffsetTime.now(clock);
 228             assertEquals(test.getHour(), (i / (60 * 60)) % 24);
 229             assertEquals(test.getMinute(), (i / 60) % 60);
 230             assertEquals(test.getSecond(), i % 60);
 231             assertEquals(test.getNano(), 8);
 232             assertEquals(test.getOffset(), ZoneOffset.UTC);
 233         }
 234     }
 235 
 236     @Test
 237     public void now_Clock_beforeEpoch() {
 238         for (int i =-1; i >= -(24 * 60 * 60); i--) {
 239             Instant instant = Instant.ofEpochSecond(i, 8);
 240             Clock clock = Clock.fixed(instant, ZoneOffset.UTC);
 241             OffsetTime test = OffsetTime.now(clock);
 242             assertEquals(test.getHour(), ((i + 24 * 60 * 60) / (60 * 60)) % 24);
 243             assertEquals(test.getMinute(), ((i + 24 * 60 * 60) / 60) % 60);
 244             assertEquals(test.getSecond(), (i + 24 * 60 * 60) % 60);
 245             assertEquals(test.getNano(), 8);
 246             assertEquals(test.getOffset(), ZoneOffset.UTC);
 247         }
 248     }
 249 
 250     @Test
 251     public void now_Clock_offsets() {
 252         Instant base = LocalDateTime.of(1970, 1, 1, 12, 0).toInstant(ZoneOffset.UTC);
 253         for (int i = -9; i < 15; i++) {
 254             ZoneOffset offset = ZoneOffset.ofHours(i);
 255             Clock clock = Clock.fixed(base, offset);
 256             OffsetTime test = OffsetTime.now(clock);
 257             assertEquals(test.getHour(), (12 + i) % 24);
 258             assertEquals(test.getMinute(), 0);
 259             assertEquals(test.getSecond(), 0);
 260             assertEquals(test.getNano(), 0);
 261             assertEquals(test.getOffset(), offset);
 262         }
 263     }
 264 
 265     @Test(expectedExceptions=NullPointerException.class)
 266     public void now_Clock_nullZoneId() {
 267         OffsetTime.now((ZoneId) null);
 268     }
 269 
 270     @Test(expectedExceptions=NullPointerException.class)
 271     public void now_Clock_nullClock() {
 272         OffsetTime.now((Clock) null);
 273     }
 274 
 275     //-----------------------------------------------------------------------
 276     // factories
 277     //-----------------------------------------------------------------------
 278     private void check(OffsetTime test, int h, int m, int s, int n, ZoneOffset offset) {
 279         assertEquals(test.toLocalTime(), LocalTime.of(h, m, s, n));
 280         assertEquals(test.getOffset(), offset);
 281 
 282         assertEquals(test.getHour(), h);
 283         assertEquals(test.getMinute(), m);
 284         assertEquals(test.getSecond(), s);
 285         assertEquals(test.getNano(), n);
 286 
 287         assertEquals(test, test);
 288         assertEquals(test.hashCode(), test.hashCode());
 289         assertEquals(OffsetTime.of(LocalTime.of(h, m, s, n), offset), test);
 290     }
 291 
 292     //-----------------------------------------------------------------------
 293     @Test
 294     public void factory_intsHMSN() {
 295         OffsetTime test = OffsetTime.of(11, 30, 10, 500, OFFSET_PONE);
 296         check(test, 11, 30, 10, 500, OFFSET_PONE);
 297     }
 298 
 299     //-----------------------------------------------------------------------
 300     @Test
 301     public void factory_LocalTimeZoneOffset() {
 302         LocalTime localTime = LocalTime.of(11, 30, 10, 500);
 303         OffsetTime test = OffsetTime.of(localTime, OFFSET_PONE);
 304         check(test, 11, 30, 10, 500, OFFSET_PONE);
 305     }
 306 
 307     @Test(expectedExceptions=NullPointerException.class)
 308     public void factory_LocalTimeZoneOffset_nullTime() {
 309         OffsetTime.of((LocalTime) null, OFFSET_PONE);
 310     }
 311 
 312     @Test(expectedExceptions=NullPointerException.class)
 313     public void factory_LocalTimeZoneOffset_nullOffset() {
 314         LocalTime localTime = LocalTime.of(11, 30, 10, 500);
 315         OffsetTime.of(localTime, (ZoneOffset) null);
 316     }
 317 
 318     //-----------------------------------------------------------------------
 319     // ofInstant()
 320     //-----------------------------------------------------------------------
 321     @Test(expectedExceptions=NullPointerException.class)
 322     public void factory_ofInstant_nullInstant() {
 323         OffsetTime.ofInstant((Instant) null, ZoneOffset.UTC);
 324     }
 325 
 326     @Test(expectedExceptions=NullPointerException.class)
 327     public void factory_ofInstant_nullOffset() {
 328         Instant instant = Instant.ofEpochSecond(0L);
 329         OffsetTime.ofInstant(instant, (ZoneOffset) null);
 330     }
 331 
 332     @Test
 333     public void factory_ofInstant_allSecsInDay() {
 334         for (int i = 0; i < (2 * 24 * 60 * 60); i++) {
 335             Instant instant = Instant.ofEpochSecond(i, 8);
 336             OffsetTime test = OffsetTime.ofInstant(instant, ZoneOffset.UTC);
 337             assertEquals(test.getHour(), (i / (60 * 60)) % 24);
 338             assertEquals(test.getMinute(), (i / 60) % 60);
 339             assertEquals(test.getSecond(), i % 60);
 340             assertEquals(test.getNano(), 8);
 341         }
 342     }
 343 
 344     @Test
 345     public void factory_ofInstant_beforeEpoch() {
 346         for (int i =-1; i >= -(24 * 60 * 60); i--) {
 347             Instant instant = Instant.ofEpochSecond(i, 8);
 348             OffsetTime test = OffsetTime.ofInstant(instant, ZoneOffset.UTC);
 349             assertEquals(test.getHour(), ((i + 24 * 60 * 60) / (60 * 60)) % 24);
 350             assertEquals(test.getMinute(), ((i + 24 * 60 * 60) / 60) % 60);
 351             assertEquals(test.getSecond(), (i + 24 * 60 * 60) % 60);
 352             assertEquals(test.getNano(), 8);
 353         }
 354     }
 355 
 356     //-----------------------------------------------------------------------
 357     @Test
 358     public void factory_ofInstant_maxYear() {
 359         OffsetTime test = OffsetTime.ofInstant(Instant.MAX, ZoneOffset.UTC);
 360         assertEquals(test.getHour(), 23);
 361         assertEquals(test.getMinute(), 59);
 362         assertEquals(test.getSecond(), 59);
 363         assertEquals(test.getNano(), 999_999_999);
 364     }
 365 
 366     @Test
 367     public void factory_ofInstant_minYear() {
 368         OffsetTime test = OffsetTime.ofInstant(Instant.MIN, ZoneOffset.UTC);
 369         assertEquals(test.getHour(), 0);
 370         assertEquals(test.getMinute(), 0);
 371         assertEquals(test.getSecond(), 0);
 372         assertEquals(test.getNano(), 0);
 373     }
 374 
 375     //-----------------------------------------------------------------------
 376     // from(TemporalAccessor)
 377     //-----------------------------------------------------------------------
 378     @Test
 379     public void factory_from_TemporalAccessor_OT() {
 380         assertEquals(OffsetTime.from(OffsetTime.of(17, 30, 0, 0, OFFSET_PONE)), OffsetTime.of(17, 30, 0, 0, OFFSET_PONE));
 381     }
 382 
 383     @Test
 384     public void test_from_TemporalAccessor_ZDT() {
 385         ZonedDateTime base = LocalDateTime.of(2007, 7, 15, 11, 30, 59, 500).atZone(OFFSET_PONE);
 386         assertEquals(OffsetTime.from(base), TEST_11_30_59_500_PONE);
 387     }
 388 
 389     @Test(expectedExceptions=DateTimeException.class)
 390     public void factory_from_TemporalAccessor_invalid_noDerive() {
 391         OffsetTime.from(LocalDate.of(2007, 7, 15));
 392     }
 393 
 394     @Test(expectedExceptions=NullPointerException.class)
 395     public void factory_from_TemporalAccessor_null() {
 396         OffsetTime.from((TemporalAccessor) null);
 397     }
 398 
 399     //-----------------------------------------------------------------------
 400     // parse()
 401     //-----------------------------------------------------------------------
 402     @Test(dataProvider = "sampleToString")
 403     public void factory_parse_validText(int h, int m, int s, int n, String offsetId, String parsable) {
 404         OffsetTime t = OffsetTime.parse(parsable);
 405         assertNotNull(t, parsable);
 406         check(t, h, m, s, n, ZoneOffset.of(offsetId));
 407     }
 408 
 409     @DataProvider(name="sampleBadParse")
 410     Object[][] provider_sampleBadParse() {
 411         return new Object[][]{
 412                 {"00;00"},
 413                 {"12-00"},
 414                 {"-01:00"},
 415                 {"00:00:00-09"},
 416                 {"00:00:00,09"},
 417                 {"00:00:abs"},
 418                 {"11"},
 419                 {"11:30"},
 420                 {"11:30+01:00[Europe/Paris]"},
 421         };
 422     }
 423 
 424     @Test(dataProvider = "sampleBadParse", expectedExceptions={DateTimeParseException.class})
 425     public void factory_parse_invalidText(String unparsable) {
 426         OffsetTime.parse(unparsable);
 427     }
 428 
 429     //-----------------------------------------------------------------------s
 430     @Test(expectedExceptions={DateTimeParseException.class})
 431     public void factory_parse_illegalHour() {
 432         OffsetTime.parse("25:00+01:00");
 433     }
 434 
 435     @Test(expectedExceptions={DateTimeParseException.class})
 436     public void factory_parse_illegalMinute() {
 437         OffsetTime.parse("12:60+01:00");
 438     }
 439 
 440     @Test(expectedExceptions={DateTimeParseException.class})
 441     public void factory_parse_illegalSecond() {
 442         OffsetTime.parse("12:12:60+01:00");
 443     }
 444 
 445     //-----------------------------------------------------------------------
 446     // parse(DateTimeFormatter)
 447     //-----------------------------------------------------------------------
 448     @Test
 449     public void factory_parse_formatter() {
 450         DateTimeFormatter f = DateTimeFormatter.ofPattern("H m s XXX");
 451         OffsetTime test = OffsetTime.parse("11 30 0 +01:00", f);
 452         assertEquals(test, OffsetTime.of(11, 30, 0, 0, ZoneOffset.ofHours(1)));
 453     }
 454 
 455     @Test(expectedExceptions=NullPointerException.class)
 456     public void factory_parse_formatter_nullText() {
 457         DateTimeFormatter f = DateTimeFormatter.ofPattern("y M d H m s");
 458         OffsetTime.parse((String) null, f);
 459     }
 460 
 461     @Test(expectedExceptions=NullPointerException.class)
 462     public void factory_parse_formatter_nullFormatter() {
 463         OffsetTime.parse("ANY", null);
 464     }
 465 
 466     //-----------------------------------------------------------------------
 467     // constructor
 468     //-----------------------------------------------------------------------
 469     @Test(expectedExceptions=NullPointerException.class)
 470     public void constructor_nullTime() throws Throwable  {
 471         Constructor<OffsetTime> con = OffsetTime.class.getDeclaredConstructor(LocalTime.class, ZoneOffset.class);
 472         con.setAccessible(true);
 473         try {
 474             con.newInstance(null, OFFSET_PONE);
 475         } catch (InvocationTargetException ex) {
 476             throw ex.getCause();
 477         }
 478     }
 479 
 480     @Test(expectedExceptions=NullPointerException.class)
 481     public void constructor_nullOffset() throws Throwable  {
 482         Constructor<OffsetTime> con = OffsetTime.class.getDeclaredConstructor(LocalTime.class, ZoneOffset.class);
 483         con.setAccessible(true);
 484         try {
 485             con.newInstance(LocalTime.of(11, 30, 0, 0), null);
 486         } catch (InvocationTargetException ex) {
 487             throw ex.getCause();
 488         }
 489     }
 490 
 491     //-----------------------------------------------------------------------
 492     // basics
 493     //-----------------------------------------------------------------------
 494     @DataProvider(name="sampleTimes")
 495     Object[][] provider_sampleTimes() {
 496         return new Object[][] {
 497             {11, 30, 20, 500, OFFSET_PONE},
 498             {11, 0, 0, 0, OFFSET_PONE},
 499             {23, 59, 59, 999999999, OFFSET_PONE},
 500         };
 501     }
 502 
 503     @Test(dataProvider="sampleTimes")
 504     public void test_get(int h, int m, int s, int n, ZoneOffset offset) {
 505         LocalTime localTime = LocalTime.of(h, m, s, n);
 506         OffsetTime a = OffsetTime.of(localTime, offset);
 507 
 508         assertEquals(a.toLocalTime(), localTime);
 509         assertEquals(a.getOffset(), offset);
 510         assertEquals(a.toString(), localTime.toString() + offset.toString());
 511         assertEquals(a.getHour(), localTime.getHour());
 512         assertEquals(a.getMinute(), localTime.getMinute());
 513         assertEquals(a.getSecond(), localTime.getSecond());
 514         assertEquals(a.getNano(), localTime.getNano());
 515     }
 516 
 517     //-----------------------------------------------------------------------
 518     // isSupported(TemporalField)
 519     //-----------------------------------------------------------------------
 520     @Test
 521     public void test_isSupported_TemporalField() {
 522         assertEquals(TEST_11_30_59_500_PONE.isSupported((TemporalField) null), false);
 523         assertEquals(TEST_11_30_59_500_PONE.isSupported(ChronoField.NANO_OF_SECOND), true);
 524         assertEquals(TEST_11_30_59_500_PONE.isSupported(ChronoField.NANO_OF_DAY), true);
 525         assertEquals(TEST_11_30_59_500_PONE.isSupported(ChronoField.MICRO_OF_SECOND), true);
 526         assertEquals(TEST_11_30_59_500_PONE.isSupported(ChronoField.MICRO_OF_DAY), true);
 527         assertEquals(TEST_11_30_59_500_PONE.isSupported(ChronoField.MILLI_OF_SECOND), true);
 528         assertEquals(TEST_11_30_59_500_PONE.isSupported(ChronoField.MILLI_OF_DAY), true);
 529         assertEquals(TEST_11_30_59_500_PONE.isSupported(ChronoField.SECOND_OF_MINUTE), true);
 530         assertEquals(TEST_11_30_59_500_PONE.isSupported(ChronoField.SECOND_OF_DAY), true);
 531         assertEquals(TEST_11_30_59_500_PONE.isSupported(ChronoField.MINUTE_OF_HOUR), true);
 532         assertEquals(TEST_11_30_59_500_PONE.isSupported(ChronoField.MINUTE_OF_DAY), true);
 533         assertEquals(TEST_11_30_59_500_PONE.isSupported(ChronoField.HOUR_OF_AMPM), true);
 534         assertEquals(TEST_11_30_59_500_PONE.isSupported(ChronoField.CLOCK_HOUR_OF_AMPM), true);
 535         assertEquals(TEST_11_30_59_500_PONE.isSupported(ChronoField.HOUR_OF_DAY), true);
 536         assertEquals(TEST_11_30_59_500_PONE.isSupported(ChronoField.CLOCK_HOUR_OF_DAY), true);
 537         assertEquals(TEST_11_30_59_500_PONE.isSupported(ChronoField.AMPM_OF_DAY), true);
 538         assertEquals(TEST_11_30_59_500_PONE.isSupported(ChronoField.DAY_OF_WEEK), false);
 539         assertEquals(TEST_11_30_59_500_PONE.isSupported(ChronoField.ALIGNED_DAY_OF_WEEK_IN_MONTH), false);
 540         assertEquals(TEST_11_30_59_500_PONE.isSupported(ChronoField.ALIGNED_DAY_OF_WEEK_IN_YEAR), false);
 541         assertEquals(TEST_11_30_59_500_PONE.isSupported(ChronoField.DAY_OF_MONTH), false);
 542         assertEquals(TEST_11_30_59_500_PONE.isSupported(ChronoField.DAY_OF_YEAR), false);
 543         assertEquals(TEST_11_30_59_500_PONE.isSupported(ChronoField.EPOCH_DAY), false);
 544         assertEquals(TEST_11_30_59_500_PONE.isSupported(ChronoField.ALIGNED_WEEK_OF_MONTH), false);
 545         assertEquals(TEST_11_30_59_500_PONE.isSupported(ChronoField.ALIGNED_WEEK_OF_YEAR), false);
 546         assertEquals(TEST_11_30_59_500_PONE.isSupported(ChronoField.MONTH_OF_YEAR), false);
 547         assertEquals(TEST_11_30_59_500_PONE.isSupported(ChronoField.PROLEPTIC_MONTH), false);
 548         assertEquals(TEST_11_30_59_500_PONE.isSupported(ChronoField.YEAR), false);
 549         assertEquals(TEST_11_30_59_500_PONE.isSupported(ChronoField.YEAR_OF_ERA), false);
 550         assertEquals(TEST_11_30_59_500_PONE.isSupported(ChronoField.ERA), false);
 551         assertEquals(TEST_11_30_59_500_PONE.isSupported(ChronoField.INSTANT_SECONDS), false);
 552         assertEquals(TEST_11_30_59_500_PONE.isSupported(ChronoField.OFFSET_SECONDS), true);
 553     }
 554 
 555     //-----------------------------------------------------------------------
 556     // isSupported(TemporalUnit)
 557     //-----------------------------------------------------------------------
 558     @Test
 559     public void test_isSupported_TemporalUnit() {
 560         assertEquals(TEST_11_30_59_500_PONE.isSupported((TemporalUnit) null), false);
 561         assertEquals(TEST_11_30_59_500_PONE.isSupported(ChronoUnit.NANOS), true);
 562         assertEquals(TEST_11_30_59_500_PONE.isSupported(ChronoUnit.MICROS), true);
 563         assertEquals(TEST_11_30_59_500_PONE.isSupported(ChronoUnit.MILLIS), true);
 564         assertEquals(TEST_11_30_59_500_PONE.isSupported(ChronoUnit.SECONDS), true);
 565         assertEquals(TEST_11_30_59_500_PONE.isSupported(ChronoUnit.MINUTES), true);
 566         assertEquals(TEST_11_30_59_500_PONE.isSupported(ChronoUnit.HOURS), true);
 567         assertEquals(TEST_11_30_59_500_PONE.isSupported(ChronoUnit.HALF_DAYS), true);
 568         assertEquals(TEST_11_30_59_500_PONE.isSupported(ChronoUnit.DAYS), false);
 569         assertEquals(TEST_11_30_59_500_PONE.isSupported(ChronoUnit.WEEKS), false);
 570         assertEquals(TEST_11_30_59_500_PONE.isSupported(ChronoUnit.MONTHS), false);
 571         assertEquals(TEST_11_30_59_500_PONE.isSupported(ChronoUnit.YEARS), false);
 572         assertEquals(TEST_11_30_59_500_PONE.isSupported(ChronoUnit.DECADES), false);
 573         assertEquals(TEST_11_30_59_500_PONE.isSupported(ChronoUnit.CENTURIES), false);
 574         assertEquals(TEST_11_30_59_500_PONE.isSupported(ChronoUnit.MILLENNIA), false);
 575         assertEquals(TEST_11_30_59_500_PONE.isSupported(ChronoUnit.ERAS), false);
 576         assertEquals(TEST_11_30_59_500_PONE.isSupported(ChronoUnit.FOREVER), false);
 577     }
 578 
 579     //-----------------------------------------------------------------------
 580     // get(TemporalField)
 581     //-----------------------------------------------------------------------
 582     @Test
 583     public void test_get_TemporalField() {
 584         OffsetTime test = OffsetTime.of(12, 30, 40, 987654321, OFFSET_PONE);
 585         assertEquals(test.get(ChronoField.HOUR_OF_DAY), 12);
 586         assertEquals(test.get(ChronoField.MINUTE_OF_HOUR), 30);
 587         assertEquals(test.get(ChronoField.SECOND_OF_MINUTE), 40);
 588         assertEquals(test.get(ChronoField.NANO_OF_SECOND), 987654321);
 589         assertEquals(test.get(ChronoField.HOUR_OF_AMPM), 0);
 590         assertEquals(test.get(ChronoField.AMPM_OF_DAY), 1);
 591 
 592         assertEquals(test.get(ChronoField.OFFSET_SECONDS), 3600);
 593     }
 594 
 595     @Test
 596     public void test_getLong_TemporalField() {
 597         OffsetTime test = OffsetTime.of(12, 30, 40, 987654321, OFFSET_PONE);
 598         assertEquals(test.getLong(ChronoField.HOUR_OF_DAY), 12);
 599         assertEquals(test.getLong(ChronoField.MINUTE_OF_HOUR), 30);
 600         assertEquals(test.getLong(ChronoField.SECOND_OF_MINUTE), 40);
 601         assertEquals(test.getLong(ChronoField.NANO_OF_SECOND), 987654321);
 602         assertEquals(test.getLong(ChronoField.HOUR_OF_AMPM), 0);
 603         assertEquals(test.getLong(ChronoField.AMPM_OF_DAY), 1);
 604 
 605         assertEquals(test.getLong(ChronoField.OFFSET_SECONDS), 3600);
 606     }
 607 
 608     //-----------------------------------------------------------------------
 609     // query(TemporalQuery)
 610     //-----------------------------------------------------------------------
 611     @DataProvider(name="query")
 612     Object[][] data_query() {
 613         return new Object[][] {
 614                 {TEST_11_30_59_500_PONE, TemporalQueries.chronology(), null},
 615                 {TEST_11_30_59_500_PONE, TemporalQueries.zoneId(), null},
 616                 {TEST_11_30_59_500_PONE, TemporalQueries.precision(), ChronoUnit.NANOS},
 617                 {TEST_11_30_59_500_PONE, TemporalQueries.zone(), OFFSET_PONE},
 618                 {TEST_11_30_59_500_PONE, TemporalQueries.offset(), OFFSET_PONE},
 619                 {TEST_11_30_59_500_PONE, TemporalQueries.localDate(), null},
 620                 {TEST_11_30_59_500_PONE, TemporalQueries.localTime(), LocalTime.of(11, 30, 59, 500)},
 621         };
 622     }
 623 
 624     @Test(dataProvider="query")
 625     public <T> void test_query(TemporalAccessor temporal, TemporalQuery<T> query, T expected) {
 626         assertEquals(temporal.query(query), expected);
 627     }
 628 
 629     @Test(dataProvider="query")
 630     public <T> void test_queryFrom(TemporalAccessor temporal, TemporalQuery<T> query, T expected) {
 631         assertEquals(query.queryFrom(temporal), expected);
 632     }
 633 
 634     @Test(expectedExceptions=NullPointerException.class)
 635     public void test_query_null() {
 636         TEST_11_30_59_500_PONE.query(null);
 637     }
 638 
 639     //-----------------------------------------------------------------------
 640     // withOffsetSameLocal()
 641     //-----------------------------------------------------------------------
 642     @Test
 643     public void test_withOffsetSameLocal() {
 644         OffsetTime base = OffsetTime.of(11, 30, 59, 0, OFFSET_PONE);
 645         OffsetTime test = base.withOffsetSameLocal(OFFSET_PTWO);
 646         assertEquals(test.toLocalTime(), base.toLocalTime());
 647         assertEquals(test.getOffset(), OFFSET_PTWO);
 648     }
 649 
 650     @Test
 651     public void test_withOffsetSameLocal_noChange() {
 652         OffsetTime base = OffsetTime.of(11, 30, 59, 0, OFFSET_PONE);
 653         OffsetTime test = base.withOffsetSameLocal(OFFSET_PONE);
 654         assertEquals(test, base);
 655     }
 656 
 657     @Test(expectedExceptions=NullPointerException.class)
 658     public void test_withOffsetSameLocal_null() {
 659         OffsetTime base = OffsetTime.of(11, 30, 59, 0, OFFSET_PONE);
 660         base.withOffsetSameLocal(null);
 661     }
 662 
 663     //-----------------------------------------------------------------------
 664     // withOffsetSameInstant()
 665     //-----------------------------------------------------------------------
 666     @Test
 667     public void test_withOffsetSameInstant() {
 668         OffsetTime base = OffsetTime.of(11, 30, 59, 0, OFFSET_PONE);
 669         OffsetTime test = base.withOffsetSameInstant(OFFSET_PTWO);
 670         OffsetTime expected = OffsetTime.of(12, 30, 59, 0, OFFSET_PTWO);
 671         assertEquals(test, expected);
 672     }
 673 
 674     @Test
 675     public void test_withOffsetSameInstant_noChange() {
 676         OffsetTime base = OffsetTime.of(11, 30, 59, 0, OFFSET_PONE);
 677         OffsetTime test = base.withOffsetSameInstant(OFFSET_PONE);
 678         assertEquals(test, base);
 679     }
 680 
 681     @Test(expectedExceptions=NullPointerException.class)
 682     public void test_withOffsetSameInstant_null() {
 683         OffsetTime base = OffsetTime.of(11, 30, 59, 0, OFFSET_PONE);
 684         base.withOffsetSameInstant(null);
 685     }
 686 
 687     //-----------------------------------------------------------------------
 688     // adjustInto(Temporal)
 689     //-----------------------------------------------------------------------
 690     @DataProvider(name="adjustInto")
 691     Object[][] data_adjustInto() {
 692         return new Object[][]{
 693                 {OffsetTime.of(LocalTime.of(23, 5), OFFSET_PONE), OffsetTime.of(LocalTime.of(1, 1, 1, 100), ZoneOffset.UTC), OffsetTime.of(LocalTime.of(23, 5), OFFSET_PONE), null},
 694                 {OffsetTime.of(LocalTime.of(23, 5), OFFSET_PONE), OffsetTime.MAX, OffsetTime.of(LocalTime.of(23, 5), OFFSET_PONE), null},
 695                 {OffsetTime.of(LocalTime.of(23, 5), OFFSET_PONE), OffsetTime.MIN, OffsetTime.of(LocalTime.of(23 , 5), OFFSET_PONE), null},
 696                 {OffsetTime.MAX, OffsetTime.of(LocalTime.of(23, 5), OFFSET_PONE), OffsetTime.of(OffsetTime.MAX.toLocalTime(), ZoneOffset.ofHours(-18)), null},
 697                 {OffsetTime.MIN, OffsetTime.of(LocalTime.of(23, 5), OFFSET_PONE), OffsetTime.of(OffsetTime.MIN.toLocalTime(), ZoneOffset.ofHours(18)), null},
 698 
 699 
 700                 {OffsetTime.of(LocalTime.of(23, 5), OFFSET_PONE), ZonedDateTime.of(LocalDateTime.of(2012, 3, 4, 1, 1, 1, 100), ZONE_GAZA), ZonedDateTime.of(LocalDateTime.of(2012, 3, 4, 23, 5), ZONE_GAZA), null},
 701                 {OffsetTime.of(LocalTime.of(23, 5), OFFSET_PONE), OffsetDateTime.of(LocalDateTime.of(2012, 3, 4, 1, 1, 1, 100), ZoneOffset.UTC), OffsetDateTime.of(LocalDateTime.of(2012, 3, 4, 23, 5), OFFSET_PONE), null},
 702 
 703                 {OffsetTime.of(LocalTime.of(23, 5), OFFSET_PONE), LocalDateTime.of(2012, 3, 4, 1, 1, 1, 100), null, DateTimeException.class},
 704                 {OffsetTime.of(LocalTime.of(23, 5), OFFSET_PONE), LocalDate.of(2210, 2, 2), null, DateTimeException.class},
 705                 {OffsetTime.of(LocalTime.of(23, 5), OFFSET_PONE), LocalTime.of(22, 3, 0), null, DateTimeException.class},
 706                 {OffsetTime.of(LocalTime.of(23, 5), OFFSET_PONE), null, null, NullPointerException.class},
 707 
 708         };
 709     }
 710 
 711     @Test(dataProvider="adjustInto")
 712     public void test_adjustInto(OffsetTime test, Temporal temporal, Temporal expected, Class<?> expectedEx) {
 713         if (expectedEx == null) {
 714             Temporal result = test.adjustInto(temporal);
 715             assertEquals(result, expected);
 716         } else {
 717             try {
 718                 Temporal result = test.adjustInto(temporal);
 719                 fail();
 720             } catch (Exception ex) {
 721                 assertTrue(expectedEx.isInstance(ex));
 722             }
 723         }
 724     }
 725 
 726     //-----------------------------------------------------------------------
 727     // with(WithAdjuster)
 728     //-----------------------------------------------------------------------
 729     @Test
 730     public void test_with_adjustment() {
 731         final OffsetTime sample = OffsetTime.of(23, 5, 0, 0, OFFSET_PONE);
 732         TemporalAdjuster adjuster = new TemporalAdjuster() {
 733             @Override
 734             public Temporal adjustInto(Temporal dateTime) {
 735                 return sample;
 736             }
 737         };
 738         assertEquals(TEST_11_30_59_500_PONE.with(adjuster), sample);
 739     }
 740 
 741     @Test
 742     public void test_with_adjustment_LocalTime() {
 743         OffsetTime test = TEST_11_30_59_500_PONE.with(LocalTime.of(13, 30));
 744         assertEquals(test, OffsetTime.of(13, 30, 0, 0, OFFSET_PONE));
 745     }
 746 
 747     @Test
 748     public void test_with_adjustment_OffsetTime() {
 749         OffsetTime test = TEST_11_30_59_500_PONE.with(OffsetTime.of(13, 35, 0, 0, OFFSET_PTWO));
 750         assertEquals(test, OffsetTime.of(13, 35, 0, 0, OFFSET_PTWO));
 751     }
 752 
 753     @Test
 754     public void test_with_adjustment_ZoneOffset() {
 755         OffsetTime test = TEST_11_30_59_500_PONE.with(OFFSET_PTWO);
 756         assertEquals(test, OffsetTime.of(11, 30, 59, 500, OFFSET_PTWO));
 757     }
 758 
 759     @Test
 760     public void test_with_adjustment_AmPm() {
 761         OffsetTime test = TEST_11_30_59_500_PONE.with(new TemporalAdjuster() {
 762             @Override
 763             public Temporal adjustInto(Temporal dateTime) {
 764                 return dateTime.with(HOUR_OF_DAY, 23);
 765             }
 766         });
 767         assertEquals(test, OffsetTime.of(23, 30, 59, 500, OFFSET_PONE));
 768     }
 769 
 770     @Test(expectedExceptions=NullPointerException.class)
 771     public void test_with_adjustment_null() {
 772         TEST_11_30_59_500_PONE.with((TemporalAdjuster) null);
 773     }
 774 
 775     //-----------------------------------------------------------------------
 776     // with(TemporalField, long)
 777     //-----------------------------------------------------------------------
 778     @Test
 779     public void test_with_TemporalField() {
 780         OffsetTime test = OffsetTime.of(12, 30, 40, 987654321, OFFSET_PONE);
 781         assertEquals(test.with(ChronoField.HOUR_OF_DAY, 15), OffsetTime.of(15, 30, 40, 987654321, OFFSET_PONE));
 782         assertEquals(test.with(ChronoField.MINUTE_OF_HOUR, 50), OffsetTime.of(12, 50, 40, 987654321, OFFSET_PONE));
 783         assertEquals(test.with(ChronoField.SECOND_OF_MINUTE, 50), OffsetTime.of(12, 30, 50, 987654321, OFFSET_PONE));
 784         assertEquals(test.with(ChronoField.NANO_OF_SECOND, 12345), OffsetTime.of(12, 30, 40, 12345, OFFSET_PONE));
 785         assertEquals(test.with(ChronoField.HOUR_OF_AMPM, 6), OffsetTime.of(18, 30, 40, 987654321, OFFSET_PONE));
 786         assertEquals(test.with(ChronoField.AMPM_OF_DAY, 0), OffsetTime.of(0, 30, 40, 987654321, OFFSET_PONE));
 787 
 788         assertEquals(test.with(ChronoField.OFFSET_SECONDS, 7205), OffsetTime.of(12, 30, 40, 987654321, ZoneOffset.ofHoursMinutesSeconds(2, 0, 5)));
 789     }
 790 
 791     @Test(expectedExceptions=NullPointerException.class )
 792     public void test_with_TemporalField_null() {
 793         TEST_11_30_59_500_PONE.with((TemporalField) null, 0);
 794     }
 795 
 796     @Test(expectedExceptions=DateTimeException.class )
 797     public void test_with_TemporalField_invalidField() {
 798         TEST_11_30_59_500_PONE.with(ChronoField.YEAR, 0);
 799     }
 800 
 801     //-----------------------------------------------------------------------
 802     // withHour()
 803     //-----------------------------------------------------------------------
 804     @Test
 805     public void test_withHour_normal() {
 806         OffsetTime base = OffsetTime.of(11, 30, 59, 0, OFFSET_PONE);
 807         OffsetTime test = base.withHour(15);
 808         assertEquals(test, OffsetTime.of(15, 30, 59, 0, OFFSET_PONE));
 809     }
 810 
 811     @Test
 812     public void test_withHour_noChange() {
 813         OffsetTime base = OffsetTime.of(11, 30, 59, 0, OFFSET_PONE);
 814         OffsetTime test = base.withHour(11);
 815         assertEquals(test, base);
 816     }
 817 
 818     //-----------------------------------------------------------------------
 819     // withMinute()
 820     //-----------------------------------------------------------------------
 821     @Test
 822     public void test_withMinute_normal() {
 823         OffsetTime base = OffsetTime.of(11, 30, 59, 0, OFFSET_PONE);
 824         OffsetTime test = base.withMinute(15);
 825         assertEquals(test, OffsetTime.of(11, 15, 59, 0, OFFSET_PONE));
 826     }
 827 
 828     @Test
 829     public void test_withMinute_noChange() {
 830         OffsetTime base = OffsetTime.of(11, 30, 59, 0, OFFSET_PONE);
 831         OffsetTime test = base.withMinute(30);
 832         assertEquals(test, base);
 833     }
 834 
 835     //-----------------------------------------------------------------------
 836     // withSecond()
 837     //-----------------------------------------------------------------------
 838     @Test
 839     public void test_withSecond_normal() {
 840         OffsetTime base = OffsetTime.of(11, 30, 59, 0, OFFSET_PONE);
 841         OffsetTime test = base.withSecond(15);
 842         assertEquals(test, OffsetTime.of(11, 30, 15, 0, OFFSET_PONE));
 843     }
 844 
 845     @Test
 846     public void test_withSecond_noChange() {
 847         OffsetTime base = OffsetTime.of(11, 30, 59, 0, OFFSET_PONE);
 848         OffsetTime test = base.withSecond(59);
 849         assertEquals(test, base);
 850     }
 851 
 852     //-----------------------------------------------------------------------
 853     // withNano()
 854     //-----------------------------------------------------------------------
 855     @Test
 856     public void test_withNanoOfSecond_normal() {
 857         OffsetTime base = OffsetTime.of(11, 30, 59, 1, OFFSET_PONE);
 858         OffsetTime test = base.withNano(15);
 859         assertEquals(test, OffsetTime.of(11, 30, 59, 15, OFFSET_PONE));
 860     }
 861 
 862     @Test
 863     public void test_withNanoOfSecond_noChange() {
 864         OffsetTime base = OffsetTime.of(11, 30, 59, 1, OFFSET_PONE);
 865         OffsetTime test = base.withNano(1);
 866         assertEquals(test, base);
 867     }
 868 
 869     //-----------------------------------------------------------------------
 870     // truncatedTo(TemporalUnit)
 871     //-----------------------------------------------------------------------
 872     @Test
 873     public void test_truncatedTo_normal() {
 874         assertEquals(TEST_11_30_59_500_PONE.truncatedTo(NANOS), TEST_11_30_59_500_PONE);
 875         assertEquals(TEST_11_30_59_500_PONE.truncatedTo(SECONDS), TEST_11_30_59_500_PONE.withNano(0));
 876         assertEquals(TEST_11_30_59_500_PONE.truncatedTo(DAYS), TEST_11_30_59_500_PONE.with(LocalTime.MIDNIGHT));
 877     }
 878 
 879     @Test(expectedExceptions=NullPointerException.class)
 880     public void test_truncatedTo_null() {
 881         TEST_11_30_59_500_PONE.truncatedTo(null);
 882     }
 883 
 884     //-----------------------------------------------------------------------
 885     // plus(PlusAdjuster)
 886     //-----------------------------------------------------------------------
 887     @Test
 888     public void test_plus_PlusAdjuster() {
 889         MockSimplePeriod period = MockSimplePeriod.of(7, ChronoUnit.MINUTES);
 890         OffsetTime t = TEST_11_30_59_500_PONE.plus(period);
 891         assertEquals(t, OffsetTime.of(11, 37, 59, 500, OFFSET_PONE));
 892     }
 893 
 894     @Test
 895     public void test_plus_PlusAdjuster_noChange() {
 896         OffsetTime t = TEST_11_30_59_500_PONE.plus(MockSimplePeriod.of(0, SECONDS));
 897         assertEquals(t, TEST_11_30_59_500_PONE);
 898     }
 899 
 900     @Test
 901     public void test_plus_PlusAdjuster_zero() {
 902         OffsetTime t = TEST_11_30_59_500_PONE.plus(Period.ZERO);
 903         assertEquals(t, TEST_11_30_59_500_PONE);
 904     }
 905 
 906     @Test(expectedExceptions=NullPointerException.class)
 907     public void test_plus_PlusAdjuster_null() {
 908         TEST_11_30_59_500_PONE.plus((TemporalAmount) null);
 909     }
 910 
 911     //-----------------------------------------------------------------------
 912     // plusHours()
 913     //-----------------------------------------------------------------------
 914     @Test
 915     public void test_plusHours() {
 916         OffsetTime base = OffsetTime.of(11, 30, 59, 0, OFFSET_PONE);
 917         OffsetTime test = base.plusHours(13);
 918         assertEquals(test, OffsetTime.of(0, 30, 59, 0, OFFSET_PONE));
 919     }
 920 
 921     @Test
 922     public void test_plusHours_zero() {
 923         OffsetTime base = OffsetTime.of(11, 30, 59, 0, OFFSET_PONE);
 924         OffsetTime test = base.plusHours(0);
 925         assertEquals(test, base);
 926     }
 927 
 928     //-----------------------------------------------------------------------
 929     // plusMinutes()
 930     //-----------------------------------------------------------------------
 931     @Test
 932     public void test_plusMinutes() {
 933         OffsetTime base = OffsetTime.of(11, 30, 59, 0, OFFSET_PONE);
 934         OffsetTime test = base.plusMinutes(30);
 935         assertEquals(test, OffsetTime.of(12, 0, 59, 0, OFFSET_PONE));
 936     }
 937 
 938     @Test
 939     public void test_plusMinutes_zero() {
 940         OffsetTime base = OffsetTime.of(11, 30, 59, 0, OFFSET_PONE);
 941         OffsetTime test = base.plusMinutes(0);
 942         assertEquals(test, base);
 943     }
 944 
 945     //-----------------------------------------------------------------------
 946     // plusSeconds()
 947     //-----------------------------------------------------------------------
 948     @Test
 949     public void test_plusSeconds() {
 950         OffsetTime base = OffsetTime.of(11, 30, 59, 0, OFFSET_PONE);
 951         OffsetTime test = base.plusSeconds(1);
 952         assertEquals(test, OffsetTime.of(11, 31, 0, 0, OFFSET_PONE));
 953     }
 954 
 955     @Test
 956     public void test_plusSeconds_zero() {
 957         OffsetTime base = OffsetTime.of(11, 30, 59, 0, OFFSET_PONE);
 958         OffsetTime test = base.plusSeconds(0);
 959         assertEquals(test, base);
 960     }
 961 
 962     //-----------------------------------------------------------------------
 963     // plusNanos()
 964     //-----------------------------------------------------------------------
 965     @Test
 966     public void test_plusNanos() {
 967         OffsetTime base = OffsetTime.of(11, 30, 59, 0, OFFSET_PONE);
 968         OffsetTime test = base.plusNanos(1);
 969         assertEquals(test, OffsetTime.of(11, 30, 59, 1, OFFSET_PONE));
 970     }
 971 
 972     @Test
 973     public void test_plusNanos_zero() {
 974         OffsetTime base = OffsetTime.of(11, 30, 59, 0, OFFSET_PONE);
 975         OffsetTime test = base.plusNanos(0);
 976         assertEquals(test, base);
 977     }
 978 
 979     //-----------------------------------------------------------------------
 980     // minus(MinusAdjuster)
 981     //-----------------------------------------------------------------------
 982     @Test
 983     public void test_minus_MinusAdjuster() {
 984         MockSimplePeriod period = MockSimplePeriod.of(7, ChronoUnit.MINUTES);
 985         OffsetTime t = TEST_11_30_59_500_PONE.minus(period);
 986         assertEquals(t, OffsetTime.of(11, 23, 59, 500, OFFSET_PONE));
 987     }
 988 
 989     @Test
 990     public void test_minus_MinusAdjuster_noChange() {
 991         OffsetTime t = TEST_11_30_59_500_PONE.minus(MockSimplePeriod.of(0, SECONDS));
 992         assertEquals(t, TEST_11_30_59_500_PONE);
 993     }
 994 
 995     @Test
 996     public void test_minus_MinusAdjuster_zero() {
 997         OffsetTime t = TEST_11_30_59_500_PONE.minus(Period.ZERO);
 998         assertEquals(t, TEST_11_30_59_500_PONE);
 999     }
1000 
1001     @Test(expectedExceptions=NullPointerException.class)
1002     public void test_minus_MinusAdjuster_null() {
1003         TEST_11_30_59_500_PONE.minus((TemporalAmount) null);
1004     }
1005 
1006     //-----------------------------------------------------------------------
1007     // minusHours()
1008     //-----------------------------------------------------------------------
1009     @Test
1010     public void test_minusHours() {
1011         OffsetTime base = OffsetTime.of(11, 30, 59, 0, OFFSET_PONE);
1012         OffsetTime test = base.minusHours(-13);
1013         assertEquals(test, OffsetTime.of(0, 30, 59, 0, OFFSET_PONE));
1014     }
1015 
1016     @Test
1017     public void test_minusHours_zero() {
1018         OffsetTime base = OffsetTime.of(11, 30, 59, 0, OFFSET_PONE);
1019         OffsetTime test = base.minusHours(0);
1020         assertEquals(test, base);
1021     }
1022 
1023     //-----------------------------------------------------------------------
1024     // minusMinutes()
1025     //-----------------------------------------------------------------------
1026     @Test
1027     public void test_minusMinutes() {
1028         OffsetTime base = OffsetTime.of(11, 30, 59, 0, OFFSET_PONE);
1029         OffsetTime test = base.minusMinutes(50);
1030         assertEquals(test, OffsetTime.of(10, 40, 59, 0, OFFSET_PONE));
1031     }
1032 
1033     @Test
1034     public void test_minusMinutes_zero() {
1035         OffsetTime base = OffsetTime.of(11, 30, 59, 0, OFFSET_PONE);
1036         OffsetTime test = base.minusMinutes(0);
1037         assertEquals(test, base);
1038     }
1039 
1040     //-----------------------------------------------------------------------
1041     // minusSeconds()
1042     //-----------------------------------------------------------------------
1043     @Test
1044     public void test_minusSeconds() {
1045         OffsetTime base = OffsetTime.of(11, 30, 59, 0, OFFSET_PONE);
1046         OffsetTime test = base.minusSeconds(60);
1047         assertEquals(test, OffsetTime.of(11, 29, 59, 0, OFFSET_PONE));
1048     }
1049 
1050     @Test
1051     public void test_minusSeconds_zero() {
1052         OffsetTime base = OffsetTime.of(11, 30, 59, 0, OFFSET_PONE);
1053         OffsetTime test = base.minusSeconds(0);
1054         assertEquals(test, base);
1055     }
1056 
1057     //-----------------------------------------------------------------------
1058     // minusNanos()
1059     //-----------------------------------------------------------------------
1060     @Test
1061     public void test_minusNanos() {
1062         OffsetTime base = OffsetTime.of(11, 30, 59, 0, OFFSET_PONE);
1063         OffsetTime test = base.minusNanos(1);
1064         assertEquals(test, OffsetTime.of(11, 30, 58, 999999999, OFFSET_PONE));
1065     }
1066 
1067     @Test
1068     public void test_minusNanos_zero() {
1069         OffsetTime base = OffsetTime.of(11, 30, 59, 0, OFFSET_PONE);
1070         OffsetTime test = base.minusNanos(0);
1071         assertEquals(test, base);
1072     }
1073 
1074     //-----------------------------------------------------------------------
1075     // until(Temporal, TemporalUnit)
1076     //-----------------------------------------------------------------------
1077     @DataProvider(name="periodUntilUnit")
1078     Object[][] data_untilUnit() {
1079         return new Object[][] {
1080                 {OffsetTime.of(1, 1, 1, 0, OFFSET_PONE), OffsetTime.of(13, 1, 1, 0, OFFSET_PONE), HALF_DAYS, 1},
1081                 {OffsetTime.of(1, 1, 1, 0, OFFSET_PONE), OffsetTime.of(2, 1, 1, 0, OFFSET_PONE), HOURS, 1},
1082                 {OffsetTime.of(1, 1, 1, 0, OFFSET_PONE), OffsetTime.of(2, 1, 1, 0, OFFSET_PONE), MINUTES, 60},
1083                 {OffsetTime.of(1, 1, 1, 0, OFFSET_PONE), OffsetTime.of(2, 1, 1, 0, OFFSET_PONE), SECONDS, 3600},
1084                 {OffsetTime.of(1, 1, 1, 0, OFFSET_PONE), OffsetTime.of(2, 1, 1, 0, OFFSET_PONE), MILLIS, 3600*1000},
1085                 {OffsetTime.of(1, 1, 1, 0, OFFSET_PONE), OffsetTime.of(2, 1, 1, 0, OFFSET_PONE), MICROS, 3600*1000*1000L},
1086                 {OffsetTime.of(1, 1, 1, 0, OFFSET_PONE), OffsetTime.of(2, 1, 1, 0, OFFSET_PONE), NANOS, 3600*1000*1000L*1000},
1087 
1088                 {OffsetTime.of(1, 1, 1, 0, OFFSET_PONE), OffsetTime.of(14, 1, 1, 0, OFFSET_PTWO), HALF_DAYS, 1},
1089                 {OffsetTime.of(1, 1, 1, 0, OFFSET_PONE), OffsetTime.of(3, 1, 1, 0, OFFSET_PTWO), HOURS, 1},
1090                 {OffsetTime.of(1, 1, 1, 0, OFFSET_PONE), OffsetTime.of(3, 1, 1, 0, OFFSET_PTWO), MINUTES, 60},
1091                 {OffsetTime.of(1, 1, 1, 0, OFFSET_PONE), OffsetTime.of(3, 1, 1, 0, OFFSET_PTWO), SECONDS, 3600},
1092                 {OffsetTime.of(1, 1, 1, 0, OFFSET_PONE), OffsetTime.of(3, 1, 1, 0, OFFSET_PTWO), MILLIS, 3600*1000},
1093                 {OffsetTime.of(1, 1, 1, 0, OFFSET_PONE), OffsetTime.of(3, 1, 1, 0, OFFSET_PTWO), MICROS, 3600*1000*1000L},
1094                 {OffsetTime.of(1, 1, 1, 0, OFFSET_PONE), OffsetTime.of(3, 1, 1, 0, OFFSET_PTWO), NANOS, 3600*1000*1000L*1000},
1095         };
1096     }
1097 
1098     @Test(dataProvider="periodUntilUnit")
1099     public void test_until_TemporalUnit(OffsetTime offsetTime1, OffsetTime offsetTime2, TemporalUnit unit, long expected) {
1100         long amount = offsetTime1.until(offsetTime2, unit);
1101         assertEquals(amount, expected);
1102     }
1103 
1104     @Test(dataProvider="periodUntilUnit")
1105     public void test_until_TemporalUnit_negated(OffsetTime offsetTime1, OffsetTime offsetTime2, TemporalUnit unit, long expected) {
1106         long amount = offsetTime2.until(offsetTime1, unit);
1107         assertEquals(amount, -expected);
1108     }
1109 
1110     @Test(dataProvider="periodUntilUnit")
1111     public void test_until_TemporalUnit_between(OffsetTime offsetTime1, OffsetTime offsetTime2, TemporalUnit unit, long expected) {
1112         long amount = unit.between(offsetTime1, offsetTime2);
1113         assertEquals(amount, expected);
1114     }
1115 
1116     @Test
1117     public void test_until_convertedType() {
1118         OffsetTime offsetTime = OffsetTime.of(1, 1, 1, 0, OFFSET_PONE);
1119         OffsetDateTime offsetDateTime = offsetTime.plusSeconds(3).atDate(LocalDate.of(1980, 2, 10));
1120         assertEquals(offsetTime.until(offsetDateTime, SECONDS), 3);
1121     }
1122 
1123     @Test(expectedExceptions=DateTimeException.class)
1124     public void test_until_invalidType() {
1125         OffsetTime offsetTime = OffsetTime.of(1, 1, 1, 0, OFFSET_PONE);
1126         offsetTime.until(LocalDate.of(1980, 2, 10), SECONDS);
1127     }
1128 
1129     @Test(expectedExceptions=DateTimeException.class)
1130     public void test_until_invalidTemporalUnit() {
1131         OffsetTime offsetTime1 = OffsetTime.of(1, 1, 1, 0, OFFSET_PONE);
1132         OffsetTime offsetTime2 = OffsetTime.of(2, 1, 1, 0, OFFSET_PONE);
1133         offsetTime1.until(offsetTime2, MONTHS);
1134     }
1135 
1136     //-----------------------------------------------------------------------
1137     // format(DateTimeFormatter)
1138     //-----------------------------------------------------------------------
1139     @Test
1140     public void test_format_formatter() {
1141         DateTimeFormatter f = DateTimeFormatter.ofPattern("H m s");
1142         String t = OffsetTime.of(11, 30, 0, 0, OFFSET_PONE).format(f);
1143         assertEquals(t, "11 30 0");
1144     }
1145 
1146     @Test(expectedExceptions=NullPointerException.class)
1147     public void test_format_formatter_null() {
1148         OffsetTime.of(11, 30, 0, 0, OFFSET_PONE).format(null);
1149     }
1150 
1151     //-----------------------------------------------------------------------
1152     // toEpochSecond()
1153     //-----------------------------------------------------------------------
1154     @DataProvider(name="epochSecond")
1155     Object[][] provider_toEpochSecond() {
1156         return new Object[][] {
1157         {OffsetTime.of(0, 0, 0, 0, OFFSET_PTWO).toEpochSecond(), -7200},
1158         {OffsetTime.of(11, 30, 0, 0, OFFSET_PTWO).toEpochSecond(), 34200},
1159         {OffsetTime.of(0, 0, 0, 0, OFFSET_PTWO).toEpochSecond(),
1160          Instant.ofEpochSecond(-7200).getEpochSecond()},
1161         {OffsetTime.of(11, 30, 0, 0, OFFSET_PTWO).toEpochSecond(),
1162          Instant.ofEpochSecond(34200).getEpochSecond()},
1163         {OffsetTime.of(11, 30, 0, 0, OFFSET_PTWO).toEpochSecond(),
1164          OffsetDateTime.of(LocalDate.of(1970, 1, 1), LocalTime.of(11, 30), OFFSET_PTWO)
1165                        .toEpochSecond()},
1166         };
1167     }
1168     @Test(dataProvider="epochSecond")
1169     public void test_toEpochSecond(long actual, long expected) {
1170         assertEquals(actual, expected);
1171     }
1172     //-----------------------------------------------------------------------
1173     // compareTo()
1174     //-----------------------------------------------------------------------
1175     @Test
1176     public void test_compareTo_time() {
1177         OffsetTime a = OffsetTime.of(11, 29, 0, 0, OFFSET_PONE);
1178         OffsetTime b = OffsetTime.of(11, 30, 0, 0, OFFSET_PONE);  // a is before b due to time
1179         assertEquals(a.compareTo(b) < 0, true);
1180         assertEquals(b.compareTo(a) > 0, true);
1181         assertEquals(a.compareTo(a) == 0, true);
1182         assertEquals(b.compareTo(b) == 0, true);
1183         assertEquals(convertInstant(a).compareTo(convertInstant(b)) < 0, true);
1184     }
1185 
1186     @Test
1187     public void test_compareTo_offset() {
1188         OffsetTime a = OffsetTime.of(11, 30, 0, 0, OFFSET_PTWO);
1189         OffsetTime b = OffsetTime.of(11, 30, 0, 0, OFFSET_PONE);  // a is before b due to offset
1190         assertEquals(a.compareTo(b) < 0, true);
1191         assertEquals(b.compareTo(a) > 0, true);
1192         assertEquals(a.compareTo(a) == 0, true);
1193         assertEquals(b.compareTo(b) == 0, true);
1194         assertEquals(convertInstant(a).compareTo(convertInstant(b)) < 0, true);
1195     }
1196 
1197     @Test
1198     public void test_compareTo_both() {
1199         OffsetTime a = OffsetTime.of(11, 50, 0, 0, OFFSET_PTWO);
1200         OffsetTime b = OffsetTime.of(11, 20, 0, 0, OFFSET_PONE);  // a is before b on instant scale
1201         assertEquals(a.compareTo(b) < 0, true);
1202         assertEquals(b.compareTo(a) > 0, true);
1203         assertEquals(a.compareTo(a) == 0, true);
1204         assertEquals(b.compareTo(b) == 0, true);
1205         assertEquals(convertInstant(a).compareTo(convertInstant(b)) < 0, true);
1206     }
1207 
1208     @Test
1209     public void test_compareTo_bothNearStartOfDay() {
1210         OffsetTime a = OffsetTime.of(0, 10, 0, 0, OFFSET_PONE);
1211         OffsetTime b = OffsetTime.of(2, 30, 0, 0, OFFSET_PTWO);  // a is before b on instant scale
1212         assertEquals(a.compareTo(b) < 0, true);
1213         assertEquals(b.compareTo(a) > 0, true);
1214         assertEquals(a.compareTo(a) == 0, true);
1215         assertEquals(b.compareTo(b) == 0, true);
1216         assertEquals(convertInstant(a).compareTo(convertInstant(b)) < 0, true);
1217     }
1218 
1219     @Test
1220     public void test_compareTo_hourDifference() {
1221         OffsetTime a = OffsetTime.of(10, 0, 0, 0, OFFSET_PONE);
1222         OffsetTime b = OffsetTime.of(11, 0, 0, 0, OFFSET_PTWO);  // a is before b despite being same time-line time
1223         assertEquals(a.compareTo(b) < 0, true);
1224         assertEquals(b.compareTo(a) > 0, true);
1225         assertEquals(a.compareTo(a) == 0, true);
1226         assertEquals(b.compareTo(b) == 0, true);
1227         assertEquals(convertInstant(a).compareTo(convertInstant(b)) == 0, true);
1228     }
1229 
1230     @Test(expectedExceptions=NullPointerException.class)
1231     public void test_compareTo_null() {
1232         OffsetTime a = OffsetTime.of(11, 30, 59, 0, OFFSET_PONE);
1233         a.compareTo(null);
1234     }
1235 
1236     @Test(expectedExceptions=ClassCastException.class)
1237     @SuppressWarnings({"unchecked", "rawtypes"})
1238     public void compareToNonOffsetTime() {
1239        Comparable c = TEST_11_30_59_500_PONE;
1240        c.compareTo(new Object());
1241     }
1242 
1243     private Instant convertInstant(OffsetTime ot) {
1244         return DATE.atTime(ot.toLocalTime()).toInstant(ot.getOffset());
1245     }
1246 
1247     //-----------------------------------------------------------------------
1248     // isAfter() / isBefore() / isEqual()
1249     //-----------------------------------------------------------------------
1250     @Test
1251     public void test_isBeforeIsAfterIsEqual1() {
1252         OffsetTime a = OffsetTime.of(11, 30, 58, 0, OFFSET_PONE);
1253         OffsetTime b = OffsetTime.of(11, 30, 59, 0, OFFSET_PONE);  // a is before b due to time
1254         assertEquals(a.isBefore(b), true);
1255         assertEquals(a.isEqual(b), false);
1256         assertEquals(a.isAfter(b), false);
1257 
1258         assertEquals(b.isBefore(a), false);
1259         assertEquals(b.isEqual(a), false);
1260         assertEquals(b.isAfter(a), true);
1261 
1262         assertEquals(a.isBefore(a), false);
1263         assertEquals(b.isBefore(b), false);
1264 
1265         assertEquals(a.isEqual(a), true);
1266         assertEquals(b.isEqual(b), true);
1267 
1268         assertEquals(a.isAfter(a), false);
1269         assertEquals(b.isAfter(b), false);
1270     }
1271 
1272     @Test
1273     public void test_isBeforeIsAfterIsEqual1nanos() {
1274         OffsetTime a = OffsetTime.of(11, 30, 59, 3, OFFSET_PONE);
1275         OffsetTime b = OffsetTime.of(11, 30, 59, 4, OFFSET_PONE);  // a is before b due to time
1276         assertEquals(a.isBefore(b), true);
1277         assertEquals(a.isEqual(b), false);
1278         assertEquals(a.isAfter(b), false);
1279 
1280         assertEquals(b.isBefore(a), false);
1281         assertEquals(b.isEqual(a), false);
1282         assertEquals(b.isAfter(a), true);
1283 
1284         assertEquals(a.isBefore(a), false);
1285         assertEquals(b.isBefore(b), false);
1286 
1287         assertEquals(a.isEqual(a), true);
1288         assertEquals(b.isEqual(b), true);
1289 
1290         assertEquals(a.isAfter(a), false);
1291         assertEquals(b.isAfter(b), false);
1292     }
1293 
1294     @Test
1295     public void test_isBeforeIsAfterIsEqual2() {
1296         OffsetTime a = OffsetTime.of(11, 30, 59, 0, OFFSET_PTWO);
1297         OffsetTime b = OffsetTime.of(11, 30, 58, 0, OFFSET_PONE);  // a is before b due to offset
1298         assertEquals(a.isBefore(b), true);
1299         assertEquals(a.isEqual(b), false);
1300         assertEquals(a.isAfter(b), false);
1301 
1302         assertEquals(b.isBefore(a), false);
1303         assertEquals(b.isEqual(a), false);
1304         assertEquals(b.isAfter(a), true);
1305 
1306         assertEquals(a.isBefore(a), false);
1307         assertEquals(b.isBefore(b), false);
1308 
1309         assertEquals(a.isEqual(a), true);
1310         assertEquals(b.isEqual(b), true);
1311 
1312         assertEquals(a.isAfter(a), false);
1313         assertEquals(b.isAfter(b), false);
1314     }
1315 
1316     @Test
1317     public void test_isBeforeIsAfterIsEqual2nanos() {
1318         OffsetTime a = OffsetTime.of(11, 30, 59, 4, ZoneOffset.ofTotalSeconds(OFFSET_PONE.getTotalSeconds() + 1));
1319         OffsetTime b = OffsetTime.of(11, 30, 59, 3, OFFSET_PONE);  // a is before b due to offset
1320         assertEquals(a.isBefore(b), true);
1321         assertEquals(a.isEqual(b), false);
1322         assertEquals(a.isAfter(b), false);
1323 
1324         assertEquals(b.isBefore(a), false);
1325         assertEquals(b.isEqual(a), false);
1326         assertEquals(b.isAfter(a), true);
1327 
1328         assertEquals(a.isBefore(a), false);
1329         assertEquals(b.isBefore(b), false);
1330 
1331         assertEquals(a.isEqual(a), true);
1332         assertEquals(b.isEqual(b), true);
1333 
1334         assertEquals(a.isAfter(a), false);
1335         assertEquals(b.isAfter(b), false);
1336     }
1337 
1338     @Test
1339     public void test_isBeforeIsAfterIsEqual_instantComparison() {
1340         OffsetTime a = OffsetTime.of(11, 30, 59, 0, OFFSET_PTWO);
1341         OffsetTime b = OffsetTime.of(10, 30, 59, 0, OFFSET_PONE);  // a is same instant as b
1342         assertEquals(a.isBefore(b), false);
1343         assertEquals(a.isEqual(b), true);
1344         assertEquals(a.isAfter(b), false);
1345 
1346         assertEquals(b.isBefore(a), false);
1347         assertEquals(b.isEqual(a), true);
1348         assertEquals(b.isAfter(a), false);
1349 
1350         assertEquals(a.isBefore(a), false);
1351         assertEquals(b.isBefore(b), false);
1352 
1353         assertEquals(a.isEqual(a), true);
1354         assertEquals(b.isEqual(b), true);
1355 
1356         assertEquals(a.isAfter(a), false);
1357         assertEquals(b.isAfter(b), false);
1358     }
1359 
1360     @Test(expectedExceptions=NullPointerException.class)
1361     public void test_isBefore_null() {
1362         OffsetTime a = OffsetTime.of(11, 30, 59, 0, OFFSET_PONE);
1363         a.isBefore(null);
1364     }
1365 
1366     @Test(expectedExceptions=NullPointerException.class)
1367     public void test_isAfter_null() {
1368         OffsetTime a = OffsetTime.of(11, 30, 59, 0, OFFSET_PONE);
1369         a.isAfter(null);
1370     }
1371 
1372     @Test(expectedExceptions=NullPointerException.class)
1373     public void test_isEqual_null() {
1374         OffsetTime a = OffsetTime.of(11, 30, 59, 0, OFFSET_PONE);
1375         a.isEqual(null);
1376     }
1377 
1378     //-----------------------------------------------------------------------
1379     // equals() / hashCode()
1380     //-----------------------------------------------------------------------
1381     @Test(dataProvider="sampleTimes")
1382     public void test_equals_true(int h, int m, int s, int n, ZoneOffset ignored) {
1383         OffsetTime a = OffsetTime.of(h, m, s, n, OFFSET_PONE);
1384         OffsetTime b = OffsetTime.of(h, m, s, n, OFFSET_PONE);
1385         assertEquals(a.equals(b), true);
1386         assertEquals(a.hashCode() == b.hashCode(), true);
1387     }
1388     @Test(dataProvider="sampleTimes")
1389     public void test_equals_false_hour_differs(int h, int m, int s, int n, ZoneOffset ignored) {
1390         h = (h == 23 ? 22 : h);
1391         OffsetTime a = OffsetTime.of(h, m, s, n, OFFSET_PONE);
1392         OffsetTime b = OffsetTime.of(h + 1, m, s, n, OFFSET_PONE);
1393         assertEquals(a.equals(b), false);
1394     }
1395     @Test(dataProvider="sampleTimes")
1396     public void test_equals_false_minute_differs(int h, int m, int s, int n, ZoneOffset ignored) {
1397         m = (m == 59 ? 58 : m);
1398         OffsetTime a = OffsetTime.of(h, m, s, n, OFFSET_PONE);
1399         OffsetTime b = OffsetTime.of(h, m + 1, s, n, OFFSET_PONE);
1400         assertEquals(a.equals(b), false);
1401     }
1402     @Test(dataProvider="sampleTimes")
1403     public void test_equals_false_second_differs(int h, int m, int s, int n, ZoneOffset ignored) {
1404         s = (s == 59 ? 58 : s);
1405         OffsetTime a = OffsetTime.of(h, m, s, n, OFFSET_PONE);
1406         OffsetTime b = OffsetTime.of(h, m, s + 1, n, OFFSET_PONE);
1407         assertEquals(a.equals(b), false);
1408     }
1409     @Test(dataProvider="sampleTimes")
1410     public void test_equals_false_nano_differs(int h, int m, int s, int n, ZoneOffset ignored) {
1411         n = (n == 999999999 ? 999999998 : n);
1412         OffsetTime a = OffsetTime.of(h, m, s, n, OFFSET_PONE);
1413         OffsetTime b = OffsetTime.of(h, m, s, n + 1, OFFSET_PONE);
1414         assertEquals(a.equals(b), false);
1415     }
1416     @Test(dataProvider="sampleTimes")
1417     public void test_equals_false_offset_differs(int h, int m, int s, int n, ZoneOffset ignored) {
1418         OffsetTime a = OffsetTime.of(h, m, s, n, OFFSET_PONE);
1419         OffsetTime b = OffsetTime.of(h, m, s, n, OFFSET_PTWO);
1420         assertEquals(a.equals(b), false);
1421     }
1422 
1423     @Test
1424     public void test_equals_itself_true() {
1425         assertEquals(TEST_11_30_59_500_PONE.equals(TEST_11_30_59_500_PONE), true);
1426     }
1427 
1428     @Test
1429     public void test_equals_string_false() {
1430         assertEquals(TEST_11_30_59_500_PONE.equals("2007-07-15"), false);
1431     }
1432 
1433     @Test
1434     public void test_equals_null_false() {
1435         assertEquals(TEST_11_30_59_500_PONE.equals(null), false);
1436     }
1437 
1438     //-----------------------------------------------------------------------
1439     // toString()
1440     //-----------------------------------------------------------------------
1441     @DataProvider(name="sampleToString")
1442     Object[][] provider_sampleToString() {
1443         return new Object[][] {
1444             {11, 30, 59, 0, "Z", "11:30:59Z"},
1445             {11, 30, 59, 0, "+01:00", "11:30:59+01:00"},
1446             {11, 30, 59, 999000000, "Z", "11:30:59.999Z"},
1447             {11, 30, 59, 999000000, "+01:00", "11:30:59.999+01:00"},
1448             {11, 30, 59, 999000, "Z", "11:30:59.000999Z"},
1449             {11, 30, 59, 999000, "+01:00", "11:30:59.000999+01:00"},
1450             {11, 30, 59, 999, "Z", "11:30:59.000000999Z"},
1451             {11, 30, 59, 999, "+01:00", "11:30:59.000000999+01:00"},
1452         };
1453     }
1454 
1455     @Test(dataProvider="sampleToString")
1456     public void test_toString(int h, int m, int s, int n, String offsetId, String expected) {
1457         OffsetTime t = OffsetTime.of(h, m, s, n, ZoneOffset.of(offsetId));
1458         String str = t.toString();
1459         assertEquals(str, expected);
1460     }
1461 
1462 }