use of java.time.LocalDate in project jdk8u_jdk by JetBrains.
the class TCKLocalDate method test_atTime_int_int_int_int_nanoTooBig.
@Test(expectedExceptions = DateTimeException.class)
public void test_atTime_int_int_int_int_nanoTooBig() {
LocalDate t = LocalDate.of(2008, 6, 30);
t.atTime(11, 30, 40, 1000000000);
}
use of java.time.LocalDate in project jdk8u_jdk by JetBrains.
the class TCKLocalDate method test_plus_Period_positiveMonths.
//-----------------------------------------------------------------------
// plus(Period)
//-----------------------------------------------------------------------
@Test
public void test_plus_Period_positiveMonths() {
MockSimplePeriod period = MockSimplePeriod.of(7, ChronoUnit.MONTHS);
LocalDate t = TEST_2007_07_15.plus(period);
assertEquals(t, LocalDate.of(2008, 2, 15));
}
use of java.time.LocalDate in project jdk8u_jdk by JetBrains.
the class TCKLocalDate method test_plusWeeks_overMonths.
@Test
public void test_plusWeeks_overMonths() {
LocalDate t = TEST_2007_07_15.plusWeeks(9);
assertEquals(t, LocalDate.of(2007, 9, 16));
}
use of java.time.LocalDate in project jdk8u_jdk by JetBrains.
the class TCKLocalDate method test_toString.
@Test(dataProvider = "sampleToString")
public void test_toString(int y, int m, int d, String expected) {
LocalDate t = LocalDate.of(y, m, d);
String str = t.toString();
assertEquals(str, expected);
}
use of java.time.LocalDate in project jdk8u_jdk by JetBrains.
the class TCKZonedDateTime method test_get.
@Test(dataProvider = "sampleTimes")
public void test_get(int y, int o, int d, int h, int m, int s, int n, ZoneId zone) {
LocalDate localDate = LocalDate.of(y, o, d);
LocalTime localTime = LocalTime.of(h, m, s, n);
LocalDateTime localDateTime = LocalDateTime.of(localDate, localTime);
ZoneOffset offset = zone.getRules().getOffset(localDateTime);
ZonedDateTime a = ZonedDateTime.of(localDateTime, zone);
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(), localTime.getHour());
assertEquals(a.getMinute(), localTime.getMinute());
assertEquals(a.getSecond(), localTime.getSecond());
assertEquals(a.getNano(), localTime.getNano());
assertEquals(a.toLocalDate(), localDate);
assertEquals(a.toLocalTime(), localTime);
assertEquals(a.toLocalDateTime(), localDateTime);
if (zone instanceof ZoneOffset) {
assertEquals(a.toString(), localDateTime.toString() + offset.toString());
} else {
assertEquals(a.toString(), localDateTime.toString() + offset.toString() + "[" + zone.toString() + "]");
}
}
Aggregations