use of java.time.Month in project jdk8u_jdk by JetBrains.
the class TCKTemporalAdjusters method test_firstDayOfMonth_nonLeap.
@Test
public void test_firstDayOfMonth_nonLeap() {
for (Month month : Month.values()) {
for (int i = 1; i <= month.length(false); i++) {
LocalDate date = date(2007, month, i);
LocalDate test = (LocalDate) TemporalAdjusters.firstDayOfMonth().adjustInto(date);
assertEquals(test.getYear(), 2007);
assertEquals(test.getMonth(), month);
assertEquals(test.getDayOfMonth(), 1);
}
}
}
use of java.time.Month in project jdk8u_jdk by JetBrains.
the class TCKTemporalAdjusters method test_firstDayOfYear_nonLeap.
@Test
public void test_firstDayOfYear_nonLeap() {
for (Month month : Month.values()) {
for (int i = 1; i <= month.length(false); i++) {
LocalDate date = date(2007, month, i);
LocalDate test = (LocalDate) TemporalAdjusters.firstDayOfYear().adjustInto(date);
assertEquals(test.getYear(), 2007);
assertEquals(test.getMonth(), Month.JANUARY);
assertEquals(test.getDayOfMonth(), 1);
}
}
}
use of java.time.Month in project jdk8u_jdk by JetBrains.
the class TCKMonth method test_factory_int_singleton.
//-----------------------------------------------------------------------
@Test
public void test_factory_int_singleton() {
for (int i = 1; i <= MAX_LENGTH; i++) {
Month test = Month.of(i);
assertEquals(test.getValue(), i);
}
}
use of java.time.Month in project jdk8u_jdk by JetBrains.
the class TCKDateTimeTextPrinting method test_appendTextMap.
//-----------------------------------------------------------------------
@Test
public void test_appendTextMap() throws Exception {
Map<Long, String> map = new HashMap<Long, String>();
map.put(1L, "JNY");
map.put(2L, "FBY");
map.put(3L, "MCH");
map.put(4L, "APL");
map.put(5L, "MAY");
map.put(6L, "JUN");
map.put(7L, "JLY");
map.put(8L, "AGT");
map.put(9L, "SPT");
map.put(10L, "OBR");
map.put(11L, "NVR");
map.put(12L, "DBR");
builder.appendText(MONTH_OF_YEAR, map);
DateTimeFormatter f = builder.toFormatter();
LocalDateTime dt = LocalDateTime.of(2010, 1, 1, 0, 0);
for (Month month : Month.values()) {
assertEquals(f.format(dt.with(month)), map.get((long) month.getValue()));
}
}
Aggregations