use of java.time.chrono.ChronoLocalDate in project jdk8u_jdk by JetBrains.
the class TestExampleCode method test_chronoPackageExample.
@Test
public void test_chronoPackageExample() {
// Print the Thai Buddhist date
ChronoLocalDate now1 = Chronology.of("ThaiBuddhist").dateNow();
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);
// 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 today's date and the last day of the year for the Thai Buddhist Calendar.
ChronoLocalDate first = now1.with(ChronoField.DAY_OF_MONTH, 1).with(ChronoField.MONTH_OF_YEAR, 1);
ChronoLocalDate 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);
}
use of java.time.chrono.ChronoLocalDate in project jdk8u_jdk by JetBrains.
the class TestChronoLocalDate method test_date_checkGenerics_genericsMethod.
//-----------------------------------------------------------------------
public void test_date_checkGenerics_genericsMethod() {
Chronology chrono = ThaiBuddhistChronology.INSTANCE;
ChronoLocalDate date = chrono.dateNow();
date = processOK(date);
date = processClassOK(ThaiBuddhistDate.class);
date = dateSupplier();
date = processClassWeird(ThaiBuddhistDate.class);
}
use of java.time.chrono.ChronoLocalDate in project jdk8u_jdk by JetBrains.
the class TestChronoLocalDate method test_date_comparator_checkGenerics_ISO.
// this class primarily tests whether the generics work OK
//-----------------------------------------------------------------------
public void test_date_comparator_checkGenerics_ISO() {
List<ChronoLocalDate> dates = new ArrayList<>();
ChronoLocalDate date = LocalDate.of(2013, 1, 1);
// Insert dates in order, no duplicates
dates.add(date.minus(10, ChronoUnit.YEARS));
dates.add(date.minus(1, ChronoUnit.YEARS));
dates.add(date.minus(1, ChronoUnit.MONTHS));
dates.add(date.minus(1, ChronoUnit.WEEKS));
dates.add(date.minus(1, ChronoUnit.DAYS));
dates.add(date);
dates.add(date.plus(1, ChronoUnit.DAYS));
dates.add(date.plus(1, ChronoUnit.WEEKS));
dates.add(date.plus(1, ChronoUnit.MONTHS));
dates.add(date.plus(1, ChronoUnit.YEARS));
dates.add(date.plus(10, ChronoUnit.YEARS));
List<ChronoLocalDate> copy = new ArrayList<>(dates);
Collections.shuffle(copy);
Collections.sort(copy, ChronoLocalDate.timeLineOrder());
assertEquals(copy, dates);
assertTrue(ChronoLocalDate.timeLineOrder().compare(copy.get(0), copy.get(1)) < 0);
}
Aggregations