本文整理汇总了Java中java.time.chrono.ChronoLocalDate.get方法的典型用法代码示例。如果您正苦于以下问题:Java ChronoLocalDate.get方法的具体用法?Java ChronoLocalDate.get怎么用?Java ChronoLocalDate.get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.time.chrono.ChronoLocalDate
的用法示例。
在下文中一共展示了ChronoLocalDate.get方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: test_reducedWithChronoYear
import java.time.chrono.ChronoLocalDate; //导入方法依赖的package包/类
@Test(dataProvider="ReducedWithChrono")
public void test_reducedWithChronoYear(ChronoLocalDate date) {
Chronology chrono = date.getChronology();
DateTimeFormatter df
= new DateTimeFormatterBuilder().appendValueReduced(YEAR, 2, 2, LocalDate.of(2000, 1, 1))
.toFormatter()
.withChronology(chrono);
int expected = date.get(YEAR);
String input = df.format(date);
ParsePosition pos = new ParsePosition(0);
TemporalAccessor parsed = df.parseUnresolved(input, pos);
int actual = parsed.get(YEAR);
assertEquals(actual, expected,
String.format("Wrong date parsed, chrono: %s, input: %s",
chrono, input));
}
示例2: test_reducedWithChronoYearOfEra
import java.time.chrono.ChronoLocalDate; //导入方法依赖的package包/类
@Test(dataProvider="ReducedWithChrono")
public void test_reducedWithChronoYearOfEra(ChronoLocalDate date) {
Chronology chrono = date.getChronology();
DateTimeFormatter df
= new DateTimeFormatterBuilder().appendValueReduced(YEAR_OF_ERA, 2, 2, LocalDate.of(2000, 1, 1))
.toFormatter()
.withChronology(chrono);
int expected = date.get(YEAR_OF_ERA);
String input = df.format(date);
ParsePosition pos = new ParsePosition(0);
TemporalAccessor parsed = df.parseUnresolved(input, pos);
int actual = parsed.get(YEAR_OF_ERA);
assertEquals(actual, expected,
String.format("Wrong date parsed, chrono: %s, input: %s",
chrono, input));
}
示例3: test_chronoPackageExample
import java.time.chrono.ChronoLocalDate; //导入方法依赖的package包/类
@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);
}