Search in sources :

Example 21 with Month

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);
        }
    }
}
Also used : Month(java.time.Month) LocalDate(java.time.LocalDate) Test(org.testng.annotations.Test)

Example 22 with Month

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);
        }
    }
}
Also used : Month(java.time.Month) LocalDate(java.time.LocalDate) Test(org.testng.annotations.Test)

Example 23 with Month

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);
    }
}
Also used : Month(java.time.Month) Test(org.testng.annotations.Test)

Example 24 with Month

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()));
    }
}
Also used : LocalDateTime(java.time.LocalDateTime) Month(java.time.Month) HashMap(java.util.HashMap) DateTimeFormatter(java.time.format.DateTimeFormatter) Test(org.testng.annotations.Test)

Aggregations

Month (java.time.Month)24 Test (org.testng.annotations.Test)20 LocalDate (java.time.LocalDate)17 DayOfWeek (java.time.DayOfWeek)8 LocalDateTime (java.time.LocalDateTime)3 DateTimeFormatter (java.time.format.DateTimeFormatter)2 Instant (java.time.Instant)1 LocalTime (java.time.LocalTime)1 YearMonth (java.time.YearMonth)1 ZoneOffset (java.time.ZoneOffset)1 Date (java.util.Date)1 HashMap (java.util.HashMap)1