use of java.time.LocalDateTime in project jdk8u_jdk by JetBrains.
the class TCKLocalDateTime method test_plusYears_int_normal.
//-----------------------------------------------------------------------
// plusYears()
//-----------------------------------------------------------------------
@Test
public void test_plusYears_int_normal() {
LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.plusYears(1);
check(t, 2008, 7, 15, 12, 30, 40, 987654321);
}
use of java.time.LocalDateTime in project jdk8u_jdk by JetBrains.
the class TCKLocalDateTime method test_minusWeeks_overMonths.
@Test
public void test_minusWeeks_overMonths() {
LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.minusWeeks(9);
check(t, 2007, 5, 13, 12, 30, 40, 987654321);
}
use of java.time.LocalDateTime in project jdk8u_jdk by JetBrains.
the class TCKLocalDateTime method test_minusNanos_halfABillion.
//-----------------------------------------------------------------------
// minusNanos()
//-----------------------------------------------------------------------
@Test
public void test_minusNanos_halfABillion() {
LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.with(LocalTime.MIDNIGHT);
LocalDate d = t.toLocalDate().minusDays(1);
int hour = 0;
int min = 0;
int sec = 0;
int nanos = 0;
for (long i = 0; i < 3700 * 1000000000L; i += 500000000) {
t = t.minusNanos(500000000);
nanos -= 500000000;
if (nanos < 0) {
sec--;
nanos += 1000000000;
if (sec == -1) {
min--;
sec += 60;
if (min == -1) {
hour--;
min += 60;
if (hour == -1) {
hour += 24;
}
}
}
}
assertEquals(t.toLocalDate(), d);
assertEquals(t.getHour(), hour);
assertEquals(t.getMinute(), min);
assertEquals(t.getSecond(), sec);
assertEquals(t.getNano(), nanos);
}
}
use of java.time.LocalDateTime in project jdk8u_jdk by JetBrains.
the class TCKLocalDateTime method test_toString.
@Test(dataProvider = "sampleToString")
public void test_toString(int y, int m, int d, int h, int mi, int s, int n, String expected) {
LocalDateTime t = LocalDateTime.of(y, m, d, h, mi, s, n);
String str = t.toString();
assertEquals(str, expected);
}
use of java.time.LocalDateTime in project jdk8u_jdk by JetBrains.
the class TCKLocalDateTime method test_plusWeeks_overYears.
@Test
public void test_plusWeeks_overYears() {
LocalDateTime t = LocalDateTime.of(2006, 7, 16, 12, 30, 40, 987654321).plusWeeks(52);
assertEquals(t, TEST_2007_07_15_12_30_40_987654321);
}
Aggregations