Search in sources :

Example 21 with ThaiBuddhistDate

use of java.time.chrono.ThaiBuddhistDate in project jdk8u_jdk by JetBrains.

the class TCKThaiBuddhistChronology method test_LocalDateTime_adjustToBuddhistDate.

@Test
public void test_LocalDateTime_adjustToBuddhistDate() {
    ThaiBuddhistDate jdate = ThaiBuddhistChronology.INSTANCE.date(2555, 10, 29);
    LocalDateTime test = LocalDateTime.MIN.with(jdate);
    assertEquals(test, LocalDateTime.of(2012, 10, 29, 0, 0));
}
Also used : LocalDateTime(java.time.LocalDateTime) ThaiBuddhistDate(java.time.chrono.ThaiBuddhistDate) Test(org.testng.annotations.Test)

Example 22 with ThaiBuddhistDate

use of java.time.chrono.ThaiBuddhistDate in project jdk8u_jdk by JetBrains.

the class TCKThaiBuddhistChronology method test_resolve_ymaa_smart.

@Test(dataProvider = "resolve_ymaa")
public void test_resolve_ymaa_smart(int y, int m, int w, int d, ThaiBuddhistDate expected, boolean smart, boolean strict) {
    Map<TemporalField, Long> fieldValues = new HashMap<>();
    fieldValues.put(ChronoField.YEAR, (long) y);
    fieldValues.put(ChronoField.MONTH_OF_YEAR, (long) m);
    fieldValues.put(ChronoField.ALIGNED_WEEK_OF_MONTH, (long) w);
    fieldValues.put(ChronoField.ALIGNED_DAY_OF_WEEK_IN_MONTH, (long) d);
    if (smart) {
        ThaiBuddhistDate date = ThaiBuddhistChronology.INSTANCE.resolveDate(fieldValues, ResolverStyle.SMART);
        assertEquals(date, expected);
        assertEquals(fieldValues.size(), 0);
    } else {
        try {
            ThaiBuddhistChronology.INSTANCE.resolveDate(fieldValues, ResolverStyle.SMART);
            fail("Should have failed");
        } catch (DateTimeException ex) {
        // expected
        }
    }
}
Also used : ThaiBuddhistDate(java.time.chrono.ThaiBuddhistDate) TemporalField(java.time.temporal.TemporalField) DateTimeException(java.time.DateTimeException) HashMap(java.util.HashMap) Test(org.testng.annotations.Test)

Example 23 with ThaiBuddhistDate

use of java.time.chrono.ThaiBuddhistDate in project jdk8u_jdk by JetBrains.

the class TCKThaiBuddhistChronology method test_resolve_yd_strict.

@Test(dataProvider = "resolve_yd")
public void test_resolve_yd_strict(int y, int d, ThaiBuddhistDate expected, boolean smart, boolean strict) {
    Map<TemporalField, Long> fieldValues = new HashMap<>();
    fieldValues.put(ChronoField.YEAR, (long) y);
    fieldValues.put(ChronoField.DAY_OF_YEAR, (long) d);
    if (strict) {
        ThaiBuddhistDate date = ThaiBuddhistChronology.INSTANCE.resolveDate(fieldValues, ResolverStyle.STRICT);
        assertEquals(date, expected);
        assertEquals(fieldValues.size(), 0);
    } else {
        try {
            ThaiBuddhistChronology.INSTANCE.resolveDate(fieldValues, ResolverStyle.STRICT);
            fail("Should have failed");
        } catch (DateTimeException ex) {
        // expected
        }
    }
}
Also used : ThaiBuddhistDate(java.time.chrono.ThaiBuddhistDate) TemporalField(java.time.temporal.TemporalField) DateTimeException(java.time.DateTimeException) HashMap(java.util.HashMap) Test(org.testng.annotations.Test)

Example 24 with ThaiBuddhistDate

use of java.time.chrono.ThaiBuddhistDate in project jdk8u_jdk by JetBrains.

the class TCKThaiBuddhistChronology method test_LocalDate_adjustToBuddhistDate.

//-----------------------------------------------------------------------
// LocalDate.with(BuddhistDate)
//-----------------------------------------------------------------------
@Test
public void test_LocalDate_adjustToBuddhistDate() {
    ThaiBuddhistDate jdate = ThaiBuddhistChronology.INSTANCE.date(2555, 10, 29);
    LocalDate test = LocalDate.MIN.with(jdate);
    assertEquals(test, LocalDate.of(2012, 10, 29));
}
Also used : ThaiBuddhistDate(java.time.chrono.ThaiBuddhistDate) ChronoLocalDate(java.time.chrono.ChronoLocalDate) LocalDate(java.time.LocalDate) Test(org.testng.annotations.Test)

Example 25 with ThaiBuddhistDate

use of java.time.chrono.ThaiBuddhistDate in project jdk8u_jdk by JetBrains.

the class TCKThaiBuddhistChronology method test_withEra_BE.

//-----------------------------------------------------------------------
// withEra()
//-----------------------------------------------------------------------
@Test
public void test_withEra_BE() {
    ThaiBuddhistDate base = ThaiBuddhistChronology.INSTANCE.date(2555, 8, 29);
    ThaiBuddhistDate test = base.with(ChronoField.ERA, ThaiBuddhistEra.BE.getValue());
    assertEquals(test, ThaiBuddhistChronology.INSTANCE.date(2555, 8, 29));
}
Also used : ThaiBuddhistDate(java.time.chrono.ThaiBuddhistDate) Test(org.testng.annotations.Test)

Aggregations

ThaiBuddhistDate (java.time.chrono.ThaiBuddhistDate)32 Test (org.testng.annotations.Test)29 TemporalField (java.time.temporal.TemporalField)10 HashMap (java.util.HashMap)10 DateTimeException (java.time.DateTimeException)7 LocalDateTime (java.time.LocalDateTime)3 ChronoPeriod (java.time.chrono.ChronoPeriod)3 MinguoDate (java.time.chrono.MinguoDate)3 LocalDate (java.time.LocalDate)2 ChronoLocalDate (java.time.chrono.ChronoLocalDate)2 DateTimeFormatterBuilder (java.time.format.DateTimeFormatterBuilder)2 ParsePosition (java.text.ParsePosition)1 Clock (java.time.Clock)1 Instant (java.time.Instant)1 LocalTime (java.time.LocalTime)1 OffsetDateTime (java.time.OffsetDateTime)1 OffsetTime (java.time.OffsetTime)1 YearMonth (java.time.YearMonth)1 ZonedDateTime (java.time.ZonedDateTime)1 ChronoZonedDateTime (java.time.chrono.ChronoZonedDateTime)1