Search in sources :

Example 11 with ThaiBuddhistDate

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

the class TCKThaiBuddhistChronology method test_adjust2.

@Test
public void test_adjust2() {
    ThaiBuddhistDate base = ThaiBuddhistChronology.INSTANCE.date(1728, 12, 2);
    ThaiBuddhistDate test = base.with(TemporalAdjusters.lastDayOfMonth());
    assertEquals(test, ThaiBuddhistChronology.INSTANCE.date(1728, 12, 31));
}
Also used : ThaiBuddhistDate(java.time.chrono.ThaiBuddhistDate) Test(org.testng.annotations.Test)

Example 12 with ThaiBuddhistDate

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

the class TCKThaiBuddhistChronology method test_resolve_ymaa_strict.

@Test(dataProvider = "resolve_ymaa")
public void test_resolve_ymaa_strict(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 (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 13 with ThaiBuddhistDate

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

the class TCKThaiBuddhistChronology method test_periodUntilDate.

//-----------------------------------------------------------------------
// PeriodUntil()
//-----------------------------------------------------------------------
@Test
public void test_periodUntilDate() {
    ThaiBuddhistDate mdate1 = ThaiBuddhistDate.of(1, 1, 1);
    ThaiBuddhistDate mdate2 = ThaiBuddhistDate.of(2, 2, 2);
    ChronoPeriod period = mdate1.until(mdate2);
    assertEquals(period, ThaiBuddhistChronology.INSTANCE.period(1, 1, 1));
}
Also used : ChronoPeriod(java.time.chrono.ChronoPeriod) ThaiBuddhistDate(java.time.chrono.ThaiBuddhistDate) Test(org.testng.annotations.Test)

Example 14 with ThaiBuddhistDate

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

the class TCKThaiBuddhistChronology method test_adjust_toLocalDate.

//-----------------------------------------------------------------------
// BuddhistDate.with(Local*)
//-----------------------------------------------------------------------
@Test
public void test_adjust_toLocalDate() {
    ThaiBuddhistDate jdate = ThaiBuddhistChronology.INSTANCE.date(1726, 1, 4);
    ThaiBuddhistDate test = jdate.with(LocalDate.of(2012, 7, 6));
    assertEquals(test, ThaiBuddhistChronology.INSTANCE.date(2555, 7, 6));
}
Also used : ThaiBuddhistDate(java.time.chrono.ThaiBuddhistDate) Test(org.testng.annotations.Test)

Example 15 with ThaiBuddhistDate

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

the class TCKThaiBuddhistChronology method test_resolve_ymd_strict.

@Test(dataProvider = "resolve_ymd")
public void test_resolve_ymd_strict(int y, int m, int d, ThaiBuddhistDate expected, Object 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.DAY_OF_MONTH, (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)

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