Search in sources :

Example 31 with ThaiBuddhistDate

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

the class TestThaiBuddhistChronoImpl method test_ThaiBuddhistChrono_vsCalendar.

//-----------------------------------------------------------------------
// Verify  ThaiBuddhist Calendar matches java.util.Calendar for range
//-----------------------------------------------------------------------
@Test(dataProvider = "RangeVersusCalendar")
public void test_ThaiBuddhistChrono_vsCalendar(LocalDate isoStartDate, LocalDate isoEndDate) {
    Locale locale = Locale.forLanguageTag("th-TH--u-ca-buddhist");
    assertEquals(locale.toString(), "th_TH", "Unexpected locale");
    Calendar cal = java.util.Calendar.getInstance(locale);
    assertEquals(cal.getCalendarType(), "buddhist", "Unexpected calendar type");
    ThaiBuddhistDate thaiDate = ThaiBuddhistChronology.INSTANCE.date(isoStartDate);
    cal.setTimeZone(TimeZone.getTimeZone("GMT+00"));
    cal.set(Calendar.YEAR, thaiDate.get(ChronoField.YEAR));
    cal.set(Calendar.MONTH, thaiDate.get(ChronoField.MONTH_OF_YEAR) - 1);
    cal.set(Calendar.DAY_OF_MONTH, thaiDate.get(ChronoField.DAY_OF_MONTH));
    while (thaiDate.isBefore(isoEndDate)) {
        assertEquals(thaiDate.get(ChronoField.DAY_OF_MONTH), cal.get(Calendar.DAY_OF_MONTH), "Day mismatch in " + thaiDate + ";  cal: " + cal);
        assertEquals(thaiDate.get(ChronoField.MONTH_OF_YEAR), cal.get(Calendar.MONTH) + 1, "Month mismatch in " + thaiDate);
        assertEquals(thaiDate.get(ChronoField.YEAR_OF_ERA), cal.get(Calendar.YEAR), "Year mismatch in " + thaiDate);
        thaiDate = thaiDate.plus(1, ChronoUnit.DAYS);
        cal.add(Calendar.DAY_OF_MONTH, 1);
    }
}
Also used : Locale(java.util.Locale) ThaiBuddhistDate(java.time.chrono.ThaiBuddhistDate) Calendar(java.util.Calendar) Test(org.testng.annotations.Test)

Example 32 with ThaiBuddhistDate

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

the class TestChronoLocalDate method test_date_checkGenerics_genericsMethod_concreteType.

public void test_date_checkGenerics_genericsMethod_concreteType() {
    ThaiBuddhistChronology chrono = ThaiBuddhistChronology.INSTANCE;
    ThaiBuddhistDate date = chrono.dateNow();
    date = ThaiBuddhistDate.now();
    date = processOK(date);
    date = processClassOK(ThaiBuddhistDate.class);
    date = dateSupplier();
// date = processClassWeird(ThaiBuddhistDate.class);  // does not compile (correct)
}
Also used : ThaiBuddhistDate(java.time.chrono.ThaiBuddhistDate) ThaiBuddhistChronology(java.time.chrono.ThaiBuddhistChronology)

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