Search in sources :

Example 11 with ChronoLocalDate

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

the class TCKChronology method test_JapaneseChronology_dateYearDay.

@Test
public void test_JapaneseChronology_dateYearDay() {
    Chronology chrono = Chronology.of("Japanese");
    ChronoLocalDate date1 = chrono.dateYearDay(JapaneseEra.HEISEI, 8, 60);
    ChronoLocalDate date2 = chrono.date(JapaneseEra.HEISEI, 8, 2, 29);
    assertEquals(date1, JapaneseChronology.INSTANCE.dateYearDay(JapaneseEra.HEISEI, 8, 60));
    assertEquals(date2, JapaneseChronology.INSTANCE.dateYearDay(JapaneseEra.HEISEI, 8, 60));
}
Also used : ChronoLocalDate(java.time.chrono.ChronoLocalDate) HijrahChronology(java.time.chrono.HijrahChronology) ThaiBuddhistChronology(java.time.chrono.ThaiBuddhistChronology) IsoChronology(java.time.chrono.IsoChronology) Chronology(java.time.chrono.Chronology) MinguoChronology(java.time.chrono.MinguoChronology) JapaneseChronology(java.time.chrono.JapaneseChronology) Test(org.testng.annotations.Test)

Example 12 with ChronoLocalDate

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

the class TestNonIsoFormatter method test_parseLocalizedText.

@Test(dataProvider = "format_data")
public void test_parseLocalizedText(Chronology chrono, Locale formatLocale, Locale numberingLocale, ChronoLocalDate expected, String text) {
    DateTimeFormatter dtf = DateTimeFormatter.ofLocalizedDate(FormatStyle.FULL).withChronology(chrono).withLocale(formatLocale).withDecimalStyle(DecimalStyle.of(numberingLocale));
    TemporalAccessor temporal = dtf.parse(text);
    ChronoLocalDate date = chrono.date(temporal);
    assertEquals(date, expected);
}
Also used : ChronoLocalDate(java.time.chrono.ChronoLocalDate) TemporalAccessor(java.time.temporal.TemporalAccessor) DateTimeFormatter(java.time.format.DateTimeFormatter) Test(org.testng.annotations.Test)

Example 13 with ChronoLocalDate

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

the class TCKCopticSerialization method test_eraSerialization.

@Test
public void test_eraSerialization() throws IOException, ClassNotFoundException {
    Chronology chrono = Chronology.of("Coptic");
    ChronoLocalDate copticDate = chrono.date(1729, 4, 27);
    assertSerializable(copticDate);
}
Also used : ChronoLocalDate(java.time.chrono.ChronoLocalDate) Chronology(java.time.chrono.Chronology) Test(org.testng.annotations.Test) AbstractTCKTest(tck.java.time.AbstractTCKTest)

Example 14 with ChronoLocalDate

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

the class TestExampleCode method test_calendarPackageExample.

@Test
public void test_calendarPackageExample() {
    // Enumerate the list of available calendars and print today for each
    Set<Chronology> chronos = Chronology.getAvailableChronologies();
    for (Chronology chrono : chronos) {
        ChronoLocalDate date = chrono.dateNow();
        System.out.printf("   %20s: %s%n", chrono.getId(), date.toString());
    }
    // Print the Thai Buddhist date
    ThaiBuddhistDate now1 = ThaiBuddhistDate.now();
    int day = now1.get(ChronoField.DAY_OF_MONTH);
    int dow = now1.get(ChronoField.DAY_OF_WEEK);
    int month = now1.get(ChronoField.MONTH_OF_YEAR);
    int year = now1.get(ChronoField.YEAR);
    System.out.printf("  Today is %s %s %d-%s-%d%n", now1.getChronology().getId(), dow, day, month, year);
    // Print today's date and the last day of the year for the Thai Buddhist Calendar.
    ThaiBuddhistDate first = now1.with(ChronoField.DAY_OF_MONTH, 1).with(ChronoField.MONTH_OF_YEAR, 1);
    ThaiBuddhistDate last = first.plus(1, ChronoUnit.YEARS).minus(1, ChronoUnit.DAYS);
    System.out.printf("  %s: 1st of year: %s; end of year: %s%n", last.getChronology().getId(), first, last);
}
Also used : ChronoLocalDate(java.time.chrono.ChronoLocalDate) ThaiBuddhistDate(java.time.chrono.ThaiBuddhistDate) HijrahChronology(java.time.chrono.HijrahChronology) Chronology(java.time.chrono.Chronology) Test(org.testng.annotations.Test)

Example 15 with ChronoLocalDate

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

the class TestUmmAlQuraChronology method test_chronoFields.

// Test to verify the values of various chrono fields for a given hijrah date instance
@Test
public void test_chronoFields() {
    ChronoLocalDate hdate = HijrahChronology.INSTANCE.date(1434, 6, 28);
    assertEquals(hdate.get(ChronoField.ALIGNED_DAY_OF_WEEK_IN_MONTH), 3);
    assertEquals(hdate.get(ChronoField.ALIGNED_DAY_OF_WEEK_IN_YEAR), 7);
    assertEquals(hdate.get(ChronoField.ALIGNED_WEEK_OF_MONTH), 4);
    assertEquals(hdate.get(ChronoField.ALIGNED_WEEK_OF_YEAR), 25);
    assertEquals(hdate.get(ChronoField.ERA), 1);
    assertEquals(hdate.get(ChronoField.YEAR_OF_ERA), 1434);
    assertEquals(hdate.get(ChronoField.MONTH_OF_YEAR), 6);
    assertEquals(hdate.get(ChronoField.DAY_OF_MONTH), 28);
    assertEquals(hdate.get(ChronoField.DAY_OF_WEEK), 3);
    assertEquals(hdate.get(ChronoField.DAY_OF_YEAR), 175);
}
Also used : ChronoLocalDate(java.time.chrono.ChronoLocalDate) Test(org.testng.annotations.Test)

Aggregations

ChronoLocalDate (java.time.chrono.ChronoLocalDate)43 Test (org.testng.annotations.Test)34 Chronology (java.time.chrono.Chronology)28 IsoChronology (java.time.chrono.IsoChronology)19 ThaiBuddhistChronology (java.time.chrono.ThaiBuddhistChronology)18 HijrahChronology (java.time.chrono.HijrahChronology)17 MinguoChronology (java.time.chrono.MinguoChronology)17 JapaneseChronology (java.time.chrono.JapaneseChronology)15 LocalDate (java.time.LocalDate)10 DateTimeException (java.time.DateTimeException)5 ChronoPeriod (java.time.chrono.ChronoPeriod)4 Era (java.time.chrono.Era)4 DateTimeFormatter (java.time.format.DateTimeFormatter)3 TemporalAccessor (java.time.temporal.TemporalAccessor)3 TemporalField (java.time.temporal.TemporalField)3 ChronoZonedDateTime (java.time.chrono.ChronoZonedDateTime)2 ThaiBuddhistDate (java.time.chrono.ThaiBuddhistDate)2 DateTimeFormatterBuilder (java.time.format.DateTimeFormatterBuilder)2 Temporal (java.time.temporal.Temporal)2 TemporalAmount (java.time.temporal.TemporalAmount)2