APISonar


java.time.chrono.Chronology.date

> java > time > chrono > Chronology > date
java APIs time APIs chrono APIs Chronology APIs date APIs

Example 1
protected boolean isValidDate(Chronology chrono, LocalDate date) {
        try {
            if (date != null) {
                chrono.date(date);
            }
            return true;
        } catch (DateTimeException ex) {
            return false;
        }
    }
Example 2
public void test_from_TemporalAccessor(Chronology chrono) {
        LocalDate refDate = LocalDate.of(2013, 1, 1);
        ChronoLocalDate date = chrono.date(refDate);
        ChronoLocalDate test1 = ChronoLocalDate.from(date);
        assertEquals(test1, date);
        ChronoLocalDate test2 = ChronoLocalDate.from(date.atTime(LocalTime.of(12, 30)));
        assertEquals(test2, date);
        ChronoLocalDate test3 = ChronoLocalDate.from(date.atTime(LocalTime.of(12, 30)).atZone(ZoneOffset.UTC));
        assertEquals(test3, date);
    }
Example 3
private String formatMonth(YearMonth yearMonth) {
        try {
            Chronology chrono = getPrimaryChronology();
            ChronoLocalDate cDate = chrono.date(yearMonth.atDay(1));
            return monthFormatter.withLocale(getLocale()).withChronology(chrono).format(cDate);
        } catch (DateTimeException ex) {
            // Date is out of range.
            return "";
        }
    }
Example 4
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);
    }
Example 5
public void test_eraSerialization() throws IOException, ClassNotFoundException {
        Chronology chrono = Chronology.of("Coptic");
        ChronoLocalDate copticDate = chrono.date(1729, 4, 27);
        assertSerializable(copticDate);
    }
Example 6
public void test_TestServiceLoader() {
        Chronology chrono = Chronology.of("Coptic");
        ChronoLocalDate copticDate = chrono.date(1729, 4, 27);
        LocalDate ld = LocalDate.from(copticDate);
        assertEquals(ld, LocalDate.of(2013, 1, 5), "CopticDate does not match LocalDate");
    }
Example 7
public void test_ChronoZonedDateTimeSerialization(Chronology chrono) throws Exception {
        ZonedDateTime ref = LocalDate.of(2013, 1, 5).atTime(12, 1, 2, 3).atZone(ZoneId.of("GMT+01:23"));
        ChronoZonedDateTime<?> original = chrono.date(ref).atTime(ref.toLocalTime()).atZone(ref.getZone());
        assertSerializable(original);
    }
Example 8
public void test_epochSecond(Chronology chrono, Era era, int y, int m, int d, int h, int min, int s, ZoneOffset offset) {
        ChronoLocalDate chronoLd = chrono.date(era, y, m, d);
        assertEquals(chrono.epochSecond(era, y, m, d, h, min, s, offset),
                     OffsetDateTime.of(LocalDate.from(chronoLd), LocalTime.of(h, min, s), offset)
                                   .toEpochSecond());
    }
Example 9
public void test_IsoChronology_dateYearDay() {
        Chronology chrono = Chronology.of("ISO");
        ChronoLocalDate date1 = chrono.dateYearDay(IsoEra.CE, 5, 60);
        ChronoLocalDate date2 = chrono.date(IsoEra.CE, 5, 3, 1);
        assertEquals(date1, IsoChronology.INSTANCE.dateYearDay(IsoEra.CE, 5, 60));
        assertEquals(date2, IsoChronology.INSTANCE.dateYearDay(IsoEra.CE, 5, 60));
    }
Example 10
public void test_MinguoChronology_dateYearDay() {
        Chronology chrono = Chronology.of("Minguo");
        ChronoLocalDate date1 = chrono.dateYearDay(MinguoEra.ROC, 5, 60);
        ChronoLocalDate date2 = chrono.date(MinguoEra.ROC, 5, 2, 29);
        assertEquals(date1, MinguoChronology.INSTANCE.dateYearDay(MinguoEra.ROC, 5, 60));
        assertEquals(date2, MinguoChronology.INSTANCE.dateYearDay(MinguoEra.ROC, 5, 60));
    }
Example 11
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));
    }
Example 12
public void test_HijrahChronology_dateYearDay() {
        Chronology chrono = Chronology.of("Hijrah");
        ChronoLocalDate date1 = chrono.dateYearDay(HijrahEra.AH, 1434, 178);
        ChronoLocalDate date2 = chrono.date(HijrahEra.AH, 1434, 7, 1);
        assertEquals(date1, HijrahChronology.INSTANCE.dateYearDay(HijrahEra.AH, 1434, 178));
        assertEquals(date2, HijrahChronology.INSTANCE.dateYearDay(HijrahEra.AH, 1434, 178));
    }
Example 13
public void test_ThaiBuddhistChronology_dateYearDay() {
        Chronology chrono = Chronology.of("ThaiBuddhist");
        ChronoLocalDate date1 = chrono.dateYearDay(ThaiBuddhistEra.BE, 2459, 60);
        ChronoLocalDate date2 = chrono.date(ThaiBuddhistEra.BE, 2459, 2, 29);
        assertEquals(date1, ThaiBuddhistChronology.INSTANCE.dateYearDay(ThaiBuddhistEra.BE, 2459, 60));
        assertEquals(date2, ThaiBuddhistChronology.INSTANCE.dateYearDay(ThaiBuddhistEra.BE, 2459, 60));
    }