当前位置: 首页>>代码示例>>Java>>正文


Java ThaiBuddhistDate.get方法代码示例

本文整理汇总了Java中java.time.chrono.ThaiBuddhistDate.get方法的典型用法代码示例。如果您正苦于以下问题:Java ThaiBuddhistDate.get方法的具体用法?Java ThaiBuddhistDate.get怎么用?Java ThaiBuddhistDate.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.time.chrono.ThaiBuddhistDate的用法示例。


在下文中一共展示了ThaiBuddhistDate.get方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: test_reducedWithLateChronoChange

import java.time.chrono.ThaiBuddhistDate; //导入方法依赖的package包/类
@Test
public void test_reducedWithLateChronoChange() {
    ThaiBuddhistDate date = ThaiBuddhistDate.of(2543, 1, 1);
    DateTimeFormatter df
            = new DateTimeFormatterBuilder()
                    .appendValueReduced(YEAR, 2, 2, LocalDate.of(2000, 1, 1))
                    .appendLiteral(" ")
                    .appendChronologyId()
            .toFormatter();
    int expected = date.get(YEAR);
    String input = df.format(date);

    ParsePosition pos = new ParsePosition(0);
    TemporalAccessor parsed = df.parseUnresolved(input, pos);
    assertEquals(pos.getIndex(), input.length(), "Input not parsed completely");
    assertEquals(pos.getErrorIndex(), -1, "Error index should be -1 (no-error)");
    int actual = parsed.get(YEAR);
    assertEquals(actual, expected,
            String.format("Wrong date parsed, chrono: %s, input: %s",
            parsed.query(TemporalQueries.chronology()), input));

}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:23,代码来源:TestReducedParser.java

示例2: test_calendarPackageExample

import java.time.chrono.ThaiBuddhistDate; //导入方法依赖的package包/类
@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);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:30,代码来源:TestExampleCode.java


注:本文中的java.time.chrono.ThaiBuddhistDate.get方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。