@Test public void test_isBeforeIsAfterIsEqual2() { OffsetTime a = OffsetTime.of(11, 30, 59, 0, OFFSET_PTWO); OffsetTime b = OffsetTime.of(11, 30, 58, 0, OFFSET_PONE); // a is before b due to offset assertEquals(a.isBefore(b), true); assertEquals(a.isEqual(b), false); assertEquals(a.isAfter(b), false); assertEquals(b.isBefore(a), false); assertEquals(b.isEqual(a), false); assertEquals(b.isAfter(a), true); assertEquals(a.isBefore(a), false); assertEquals(b.isBefore(b), false); assertEquals(a.isEqual(a), true); assertEquals(b.isEqual(b), true); assertEquals(a.isAfter(a), false); assertEquals(b.isAfter(b), false); }
/** * Helper method for *SetObject* tests. * Validate the test data contained in the given ResultSet with following structure: * 1 - `id` INT * 2 - `ot1` VARCHAR * 3 - `ot2` BLOB * 4 - `odt1` VARCHAR * 5 - `odt2` BLOB * * Additionally validate support for the types java.time.Offset[Date]Time in ResultSet.getObject(). * * @param tableName * @param expectedRowCount * @throws Exception */ private void validateTestDataOffsetDTTypes(String tableName, int expectedRowCount) throws Exception { Connection testConn = getConnectionWithProps("autoDeserialize=true"); // Offset[Date]Time are supported via object serialization too. Statement testStmt = testConn.createStatement(); this.rs = testStmt.executeQuery("SELECT * FROM " + tableName); int rowCount = 0; while (rs.next()) { String row = "Row " + rs.getInt(1); assertEquals(++rowCount, rs.getInt(1)); assertEquals(row, testOffsetTime, this.rs.getObject(2, OffsetTime.class)); assertEquals(row, testOffsetTime, this.rs.getObject(3, OffsetTime.class)); assertEquals(row, testOffsetDateTime, this.rs.getObject(4, OffsetDateTime.class)); assertEquals(row, testOffsetDateTime, this.rs.getObject(5, OffsetDateTime.class)); assertEquals(row, rowCount, this.rs.getInt("id")); assertEquals(row, testOffsetTime, this.rs.getObject("ot1", OffsetTime.class)); assertEquals(row, testOffsetTime, this.rs.getObject("ot2", OffsetTime.class)); assertEquals(row, testOffsetDateTime, this.rs.getObject("odt1", OffsetDateTime.class)); assertEquals(row, testOffsetDateTime, this.rs.getObject("odt2", OffsetDateTime.class)); } assertEquals(expectedRowCount, rowCount); testConn.close(); }
@Override public TemporalAccessor parse(String text, Locale locale) throws ParseException { DateTimeFormatter formatterToUse = DateTimeContextHolder.getFormatter(this.formatter, locale); if (LocalDate.class.equals(this.temporalAccessorType)) { return LocalDate.parse(text, formatterToUse); } else if (LocalTime.class.equals(this.temporalAccessorType)) { return LocalTime.parse(text, formatterToUse); } else if (LocalDateTime.class.equals(this.temporalAccessorType)) { return LocalDateTime.parse(text, formatterToUse); } else if (ZonedDateTime.class.equals(this.temporalAccessorType)) { return ZonedDateTime.parse(text, formatterToUse); } else if (OffsetDateTime.class.equals(this.temporalAccessorType)) { return OffsetDateTime.parse(text, formatterToUse); } else if (OffsetTime.class.equals(this.temporalAccessorType)) { return OffsetTime.parse(text, formatterToUse); } else { throw new IllegalStateException("Unsupported TemporalAccessor type: " + this.temporalAccessorType); } }
@Override public Tuple addValue(Object value) { if(value instanceof Boolean || value instanceof Number || value instanceof Character || value instanceof String || value instanceof JsonObject || value instanceof JsonArray || value instanceof Buffer || value instanceof LocalTime || value instanceof OffsetTime || value instanceof LocalDate || value instanceof LocalDateTime || value instanceof OffsetDateTime) { add(value); } else { add(null); } return this; }
@Test public void test_isBeforeIsAfterIsEqual1() { OffsetTime a = OffsetTime.of(11, 30, 58, 0, OFFSET_PONE); OffsetTime b = OffsetTime.of(11, 30, 59, 0, OFFSET_PONE); // a is before b due to time assertEquals(a.isBefore(b), true); assertEquals(a.isEqual(b), false); assertEquals(a.isAfter(b), false); assertEquals(b.isBefore(a), false); assertEquals(b.isEqual(a), false); assertEquals(b.isAfter(a), true); assertEquals(a.isBefore(a), false); assertEquals(b.isBefore(b), false); assertEquals(a.isEqual(a), true); assertEquals(b.isEqual(b), true); assertEquals(a.isAfter(a), false); assertEquals(b.isAfter(b), false); }
@Test(dataProvider="sampleTimes") public void test_get(int y, int o, int d, int h, int m, int s, int n, ZoneOffset offset) { LocalDate localDate = LocalDate.of(y, o, d); LocalTime localTime = LocalTime.of(h, m, s, n); LocalDateTime localDateTime = LocalDateTime.of(localDate, localTime); OffsetDateTime a = OffsetDateTime.of(localDateTime, offset); assertEquals(a.getYear(), localDate.getYear()); assertEquals(a.getMonth(), localDate.getMonth()); assertEquals(a.getDayOfMonth(), localDate.getDayOfMonth()); assertEquals(a.getDayOfYear(), localDate.getDayOfYear()); assertEquals(a.getDayOfWeek(), localDate.getDayOfWeek()); assertEquals(a.getHour(), localDateTime.getHour()); assertEquals(a.getMinute(), localDateTime.getMinute()); assertEquals(a.getSecond(), localDateTime.getSecond()); assertEquals(a.getNano(), localDateTime.getNano()); assertEquals(a.toOffsetTime(), OffsetTime.of(localTime, offset)); assertEquals(a.toString(), localDateTime.toString() + offset.toString()); }
@DataProvider(name="adjustInto") Object[][] data_adjustInto() { return new Object[][]{ {LocalDateTime.of(2012, 3, 4, 23, 5), LocalDateTime.of(2012, 3, 4, 1, 1, 1, 100), LocalDateTime.of(2012, 3, 4, 23, 5, 0, 0), null}, {LocalDateTime.of(2012, Month.MARCH, 4, 0, 0), LocalDateTime.of(2012, 3, 4, 1, 1, 1, 100), LocalDateTime.of(2012, 3, 4, 0, 0), null}, {LocalDateTime.of(2012, 3, 4, 23, 5), LocalDateTime.MAX, LocalDateTime.of(2012, 3, 4, 23, 5), null}, {LocalDateTime.of(2012, 3, 4, 23, 5), LocalDateTime.MIN, LocalDateTime.of(2012, 3, 4, 23, 5), null}, {LocalDateTime.MAX, LocalDateTime.of(2012, 3, 4, 23, 5), LocalDateTime.MAX, null}, {LocalDateTime.MIN, LocalDateTime.of(2012, 3, 4, 23, 5), LocalDateTime.MIN, null}, {LocalDateTime.of(2012, 3, 4, 23, 5), OffsetDateTime.of(2210, 2, 2, 0, 0, 0, 0, ZoneOffset.UTC), OffsetDateTime.of(2012, 3, 4, 23, 5, 0, 0, ZoneOffset.UTC), null}, {LocalDateTime.of(2012, 3, 4, 23, 5), OffsetDateTime.of(2210, 2, 2, 0, 0, 0, 0, OFFSET_PONE), OffsetDateTime.of(2012, 3, 4, 23, 5, 0, 0, OFFSET_PONE), null}, {LocalDateTime.of(2012, 3, 4, 23, 5), ZonedDateTime.of(2210, 2, 2, 0, 0, 0, 0, ZONE_PARIS), ZonedDateTime.of(2012, 3, 4, 23, 5, 0, 0, ZONE_PARIS), null}, {LocalDateTime.of(2012, 3, 4, 23, 5), LocalDate.of(2210, 2, 2), null, DateTimeException.class}, {LocalDateTime.of(2012, 3, 4, 23, 5), LocalTime.of(22, 3, 0), null, DateTimeException.class}, {LocalDateTime.of(2012, 3, 4, 23, 5), OffsetTime.of(22, 3, 0, 0, ZoneOffset.UTC), null, DateTimeException.class}, {LocalDateTime.of(2012, 3, 4, 23, 5), null, null, NullPointerException.class}, }; }
@Test public void test_isBeforeIsAfterIsEqual2nanos() { OffsetTime a = OffsetTime.of(11, 30, 59, 4, ZoneOffset.ofTotalSeconds(OFFSET_PONE.getTotalSeconds() + 1)); OffsetTime b = OffsetTime.of(11, 30, 59, 3, OFFSET_PONE); // a is before b due to offset assertEquals(a.isBefore(b), true); assertEquals(a.isEqual(b), false); assertEquals(a.isAfter(b), false); assertEquals(b.isBefore(a), false); assertEquals(b.isEqual(a), false); assertEquals(b.isAfter(a), true); assertEquals(a.isBefore(a), false); assertEquals(b.isBefore(b), false); assertEquals(a.isEqual(a), true); assertEquals(b.isEqual(b), true); assertEquals(a.isAfter(a), false); assertEquals(b.isAfter(b), false); }
@Test(expectedExceptions=NullPointerException.class) public void constructor_nullOffset() throws Throwable { Constructor<OffsetTime> con = OffsetTime.class.getDeclaredConstructor(LocalTime.class, ZoneOffset.class); con.setAccessible(true); try { con.newInstance(LocalTime.of(11, 30, 0, 0), null); } catch (InvocationTargetException ex) { throw ex.getCause(); } }
@Override public void encode( BsonWriter writer, OffsetTime value, EncoderContext encoderContext) { writer.writeString(value.toString()); }
@Override public OffsetTime decode( BsonReader reader, DecoderContext decoderContext) { return OffsetTime.parse(reader.readString()); }
@Test public void test_compareTo_bothNearStartOfDay() { OffsetTime a = OffsetTime.of(0, 10, 0, 0, OFFSET_PONE); OffsetTime b = OffsetTime.of(2, 30, 0, 0, OFFSET_PTWO); // a is before b on instant scale assertEquals(a.compareTo(b) < 0, true); assertEquals(b.compareTo(a) > 0, true); assertEquals(a.compareTo(a) == 0, true); assertEquals(b.compareTo(b) == 0, true); assertEquals(convertInstant(a).compareTo(convertInstant(b)) < 0, true); }
@Test public void test_withOffsetSameInstant() { OffsetTime base = OffsetTime.of(11, 30, 59, 0, OFFSET_PONE); OffsetTime test = base.withOffsetSameInstant(OFFSET_PTWO); OffsetTime expected = OffsetTime.of(12, 30, 59, 0, OFFSET_PTWO); assertEquals(test, expected); }
@Test public void test_with_adjustment() { final OffsetTime sample = OffsetTime.of(23, 5, 0, 0, OFFSET_PONE); TemporalAdjuster adjuster = new TemporalAdjuster() { @Override public Temporal adjustInto(Temporal dateTime) { return sample; } }; assertEquals(TEST_11_30_59_500_PONE.with(adjuster), sample); }
@Test public void test_with_adjustment_AmPm() { OffsetTime test = TEST_11_30_59_500_PONE.with(new TemporalAdjuster() { @Override public Temporal adjustInto(Temporal dateTime) { return dateTime.with(HOUR_OF_DAY, 23); } }); assertEquals(test, OffsetTime.of(23, 30, 59, 500, OFFSET_PONE)); }
@Test(dataProvider="sampleTimes") public void test_equals_true(int h, int m, int s, int n, ZoneOffset ignored) { OffsetTime a = OffsetTime.of(h, m, s, n, OFFSET_PONE); OffsetTime b = OffsetTime.of(h, m, s, n, OFFSET_PONE); assertEquals(a.equals(b), true); assertEquals(a.hashCode() == b.hashCode(), true); }
@Test public void offsetTimeArray() throws CheckedFutureException { test("timetz[]", (ps, v) -> ps.setOffsetTimeArray(v), Value::getOffsetTimeArray, r -> { OffsetTime[] array = new OffsetTime[r.nextInt(10)]; for(int i = 0; i < array.length; i++) array[i] = randomLocalDateTime(r).toLocalTime().atOffset(randomZoneOffset(r)); return array; }, (a, b) -> assertArrayEquals(a, b)); }
@Override public void registerFormatters(FormatterRegistry registry) { DateTimeConverters.registerConverters(registry); DateTimeFormatter dateFormatter = getFormatter(Type.DATE); DateTimeFormatter timeFormatter = getFormatter(Type.TIME); DateTimeFormatter dateTimeFormatter = getFormatter(Type.DATE_TIME); registry.addFormatterForFieldType(LocalDate.class, new TemporalAccessorPrinter(dateFormatter), new TemporalAccessorParser(LocalDate.class, dateFormatter)); registry.addFormatterForFieldType(LocalTime.class, new TemporalAccessorPrinter(timeFormatter), new TemporalAccessorParser(LocalTime.class, timeFormatter)); registry.addFormatterForFieldType(LocalDateTime.class, new TemporalAccessorPrinter(dateTimeFormatter), new TemporalAccessorParser(LocalDateTime.class, dateTimeFormatter)); registry.addFormatterForFieldType(ZonedDateTime.class, new TemporalAccessorPrinter(dateTimeFormatter), new TemporalAccessorParser(ZonedDateTime.class, dateTimeFormatter)); registry.addFormatterForFieldType(OffsetDateTime.class, new TemporalAccessorPrinter(dateTimeFormatter), new TemporalAccessorParser(OffsetDateTime.class, dateTimeFormatter)); registry.addFormatterForFieldType(OffsetTime.class, new TemporalAccessorPrinter(timeFormatter), new TemporalAccessorParser(OffsetTime.class, timeFormatter)); registry.addFormatterForFieldType(Instant.class, new InstantFormatter()); registry.addFormatterForFieldAnnotation(new Jsr310DateTimeFormatAnnotationFormatterFactory()); }
@Override public TradingStatus statusOf(final Exchange stockExchange) { final OffsetDateTime now = now(getClock()).withZoneSameInstant(stockExchange.getOffset()) .toOffsetDateTime(); final OffsetTime offsetTime = now.toOffsetTime(); final TradingHours tradingHours = stockExchange.getTradingHours(); return (( offsetTime.isAfter(tradingHours.getOpenAt()) || offsetTime.isEqual(tradingHours.getOpenAt())) && offsetTime.isBefore(tradingHours.getCloseAt())) ? TradingStatus.OPENED : TradingStatus.CLOSED; }
/** * Tests fix for Bug#84189 - Allow null when extracting java.time.* classes from ResultSet. */ public void testBug84189() throws Exception { createTable("testBug84189", "(d DATE NULL, t TIME NULL, dt DATETIME NULL, ts TIMESTAMP NULL, ot VARCHAR(100), odt VARCHAR(100))"); this.stmt.execute( "INSERT INTO testBug84189 VALUES ('2017-01-01', '10:20:30', '2017-01-01 10:20:30', '2017-01-01 10:20:30', '10:20:30+04:00', '2017-01-01T10:20:30+04:00')"); this.stmt.execute("INSERT INTO testBug84189 VALUES (NULL, NULL, NULL, NULL, NULL, NULL)"); this.rs = this.stmt.executeQuery("SELECT * FROM testBug84189"); assertTrue(this.rs.next()); assertEquals(LocalDate.of(2017, 1, 1), this.rs.getObject(1, LocalDate.class)); assertEquals(LocalTime.of(10, 20, 30), this.rs.getObject(2, LocalTime.class)); assertEquals(LocalDateTime.of(2017, 1, 1, 10, 20, 30), this.rs.getObject(3, LocalDateTime.class)); assertEquals(LocalDateTime.of(2017, 1, 1, 10, 20, 30), this.rs.getObject(4, LocalDateTime.class)); assertEquals(OffsetTime.of(10, 20, 30, 0, ZoneOffset.ofHours(4)), this.rs.getObject(5, OffsetTime.class)); assertEquals(OffsetDateTime.of(2017, 01, 01, 10, 20, 30, 0, ZoneOffset.ofHours(4)), this.rs.getObject(6, OffsetDateTime.class)); assertEquals(LocalDate.class, this.rs.getObject(1, LocalDate.class).getClass()); assertEquals(LocalTime.class, this.rs.getObject(2, LocalTime.class).getClass()); assertEquals(LocalDateTime.class, this.rs.getObject(3, LocalDateTime.class).getClass()); assertEquals(LocalDateTime.class, this.rs.getObject(4, LocalDateTime.class).getClass()); assertEquals(OffsetTime.class, this.rs.getObject(5, OffsetTime.class).getClass()); assertEquals(OffsetDateTime.class, this.rs.getObject(6, OffsetDateTime.class).getClass()); assertTrue(this.rs.next()); assertNull(this.rs.getObject(1, LocalDate.class)); assertNull(this.rs.getObject(2, LocalTime.class)); assertNull(this.rs.getObject(3, LocalDateTime.class)); assertNull(this.rs.getObject(4, LocalDateTime.class)); assertNull(this.rs.getObject(5, OffsetTime.class)); assertNull(this.rs.getObject(6, OffsetDateTime.class)); assertFalse(this.rs.next()); }
@Test public void testOffsetTime() throws ParseException { DateTimeApiParameterMapper mapper = new DateTimeApiParameterMapper(); assertThat(mapper.toJdbc(OffsetTime.from(createDateTime("2000/01/01 10:10:10.010")), null, null), instanceOf(java.sql.Time.class)); assertThat(mapper.toJdbc(OffsetTime.from(createDateTime("2000/01/01 10:10:10.010")), null, null), is(createTime("10:10:10.010"))); }
/** * Try to obtain the {@link TemporalType} of given <code>expression</code>, if the expression type is a temporal * type. * @param expression Query expression * @param treatDateTypeAsDate <code>true</code> to return {@link TemporalType#DATE} for {@link Date} type if * temporal information is not available * @return The expression {@link TemporalType}, empty if not available or applicable */ public static Optional<TemporalType> getTemporalType(Expression expression, boolean treatDateTypeAsDate) { if (expression != null) { Class<?> type = null; if (Path.class.isAssignableFrom(expression.getClass())) { type = ((Path<?>) expression).getType(); } else if (QueryExpression.class.isAssignableFrom(expression.getClass())) { type = ((QueryExpression<?>) expression).getType(); } if (type != null) { if (LocalDate.class.isAssignableFrom(type) || ChronoLocalDate.class.isAssignableFrom(type)) { return Optional.of(TemporalType.DATE); } if (LocalTime.class.isAssignableFrom(type) || OffsetTime.class.isAssignableFrom(type)) { return Optional.of(TemporalType.TIME); } if (LocalDateTime.class.isAssignableFrom(type) || OffsetDateTime.class.isAssignableFrom(type) || ZonedDateTime.class.isAssignableFrom(type) || ChronoLocalDateTime.class.isAssignableFrom(type)) { return Optional.of(TemporalType.DATE); } if (Date.class.isAssignableFrom(type) || Calendar.class.isAssignableFrom(type)) { if (Property.class.isAssignableFrom(expression.getClass())) { Optional<TemporalType> tt = ((Property<?>) expression).getConfiguration().getTemporalType(); return treatDateTypeAsDate ? Optional.of(tt.orElse(TemporalType.DATE)) : tt; } else { return treatDateTypeAsDate ? Optional.of(TemporalType.DATE) : Optional.empty(); } } } } return Optional.empty(); }
public <T> T deserialze(DefaultJSONParser parser, Type type, Object fieldName) { JSONLexer lexer = parser.getLexer(); if (lexer.token() == 4) { String text = lexer.stringVal(); lexer.nextToken(); if (type == LocalDateTime.class) { return LocalDateTime.parse(text); } if (type == LocalDate.class) { return LocalDate.parse(text); } if (type == LocalTime.class) { return LocalTime.parse(text); } if (type == ZonedDateTime.class) { return ZonedDateTime.parse(text); } if (type == OffsetDateTime.class) { return OffsetDateTime.parse(text); } if (type == OffsetTime.class) { return OffsetTime.parse(text); } if (type == ZoneId.class) { return ZoneId.of(text); } if (type == Period.class) { return Period.parse(text); } if (type == Duration.class) { return Duration.parse(text); } if (type == Instant.class) { return Instant.parse(text); } return null; } throw new UnsupportedOperationException(); }
@Test public void test_with_adjuster_OffsetTime_validOffsetNotInOverlap() { // OT has valid offset for resulting time OffsetTime ot = OffsetTime.of(15, 50, 30, 40, OFFSET_0100); ZonedDateTime zdt = TEST_PARIS_OVERLAP_2008_10_26_02_30.atZone(ZONE_PARIS); ZonedDateTime test = zdt.with(ot); assertEquals(test.toLocalDateTime(), dateTime(2008, 10, 26, 15, 50, 30, 40)); assertEquals(test.getOffset(), OFFSET_0100); }
@Test public void test_with_adjuster_OffsetTime_invalidOffsetIgnored1() { // OT has invalid offset for ZDT, so only LT is set OffsetTime ot = OffsetTime.of(0, 50, 30, 40, OFFSET_0130); ZonedDateTime zdt = dateTime(2008, 10, 26, 2, 30, 0, 0, OFFSET_0200, ZONE_PARIS); // earlier part of overlap ZonedDateTime test = zdt.with(ot); assertEquals(test.toLocalDateTime(), dateTime(2008, 10, 26, 0, 50, 30, 40)); assertEquals(test.getOffset(), OFFSET_0200); // offset not adjusted }
@Test(dataProvider="sampleTimes") public void test_equals_false_second_differs(int h, int m, int s, int n, ZoneOffset ignored) { s = (s == 59 ? 58 : s); OffsetTime a = OffsetTime.of(h, m, s, n, OFFSET_PONE); OffsetTime b = OffsetTime.of(h, m, s + 1, n, OFFSET_PONE); assertEquals(a.equals(b), false); }
@Test public void now() { ZonedDateTime nowDT = ZonedDateTime.now(); OffsetTime expected = OffsetTime.now(Clock.systemDefaultZone()); OffsetTime test = OffsetTime.now(); long diff = Math.abs(test.toLocalTime().toNanoOfDay() - expected.toLocalTime().toNanoOfDay()); assertTrue(diff < 100000000); // less than 0.1 secs assertEquals(test.getOffset(), nowDT.getOffset()); }
@Test public void now_Clock_allSecsInDay() { for (int i = 0; i < (2 * 24 * 60 * 60); i++) { Instant instant = Instant.ofEpochSecond(i, 8); Clock clock = Clock.fixed(instant, ZoneOffset.UTC); OffsetTime test = OffsetTime.now(clock); assertEquals(test.getHour(), (i / (60 * 60)) % 24); assertEquals(test.getMinute(), (i / 60) % 60); assertEquals(test.getSecond(), i % 60); assertEquals(test.getNano(), 8); assertEquals(test.getOffset(), ZoneOffset.UTC); } }
@Test public void test_compareTo_hourDifference() { OffsetTime a = OffsetTime.of(10, 0, 0, 0, OFFSET_PONE); OffsetTime b = OffsetTime.of(11, 0, 0, 0, OFFSET_PTWO); // a is before b despite being same time-line time assertEquals(a.compareTo(b) < 0, true); assertEquals(b.compareTo(a) > 0, true); assertEquals(a.compareTo(a) == 0, true); assertEquals(b.compareTo(b) == 0, true); assertEquals(convertInstant(a).compareTo(convertInstant(b)) == 0, true); }
@Test public void test_compareTo_offset() { OffsetTime a = OffsetTime.of(11, 30, 0, 0, OFFSET_PTWO); OffsetTime b = OffsetTime.of(11, 30, 0, 0, OFFSET_PONE); // a is before b due to offset assertEquals(a.compareTo(b) < 0, true); assertEquals(b.compareTo(a) > 0, true); assertEquals(a.compareTo(a) == 0, true); assertEquals(b.compareTo(b) == 0, true); assertEquals(convertInstant(a).compareTo(convertInstant(b)) < 0, true); }
@Test public void factory_ofInstant_allSecsInDay() { for (int i = 0; i < (2 * 24 * 60 * 60); i++) { Instant instant = Instant.ofEpochSecond(i, 8); OffsetTime test = OffsetTime.ofInstant(instant, ZoneOffset.UTC); assertEquals(test.getHour(), (i / (60 * 60)) % 24); assertEquals(test.getMinute(), (i / 60) % 60); assertEquals(test.getSecond(), i % 60); assertEquals(test.getNano(), 8); } }
@Test public void test_getLong_TemporalField() { OffsetTime test = OffsetTime.of(12, 30, 40, 987654321, OFFSET_PONE); assertEquals(test.getLong(ChronoField.HOUR_OF_DAY), 12); assertEquals(test.getLong(ChronoField.MINUTE_OF_HOUR), 30); assertEquals(test.getLong(ChronoField.SECOND_OF_MINUTE), 40); assertEquals(test.getLong(ChronoField.NANO_OF_SECOND), 987654321); assertEquals(test.getLong(ChronoField.HOUR_OF_AMPM), 0); assertEquals(test.getLong(ChronoField.AMPM_OF_DAY), 1); assertEquals(test.getLong(ChronoField.OFFSET_SECONDS), 3600); }
@Test public void testOffsetTimeArrayInjection() { Assert.assertEquals(myOffsetDateTimes.length, 2); Assert.assertEquals( myOffsetTimes[0], OffsetTime.parse("13:45:30.123456789+02:00")); Assert.assertEquals( myOffsetTimes[1], OffsetTime.parse("13:45:30.123456789+03:00")); }
@Test public void test_atTime_OffsetTime() { LocalDate t = LocalDate.of(2008, 6, 30); assertEquals(t.atTime(OffsetTime.of(11, 30, 0, 0, OFFSET_PONE)), OffsetDateTime.of(2008, 6, 30, 11, 30, 0, 0, OFFSET_PONE)); }
public OffsetTime getDate() { return date; }
@Test(expectedExceptions=NullPointerException.class) public void test_withOffsetSameInstant_null() { OffsetTime base = OffsetTime.of(11, 30, 59, 0, OFFSET_PONE); base.withOffsetSameInstant(null); }
@Test public void test_plus_PlusAdjuster_noChange() { OffsetTime t = TEST_11_30_59_500_PONE.plus(MockSimplePeriod.of(0, SECONDS)); assertEquals(t, TEST_11_30_59_500_PONE); }