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


Java DateTimeFormatter.withChronology方法代码示例

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


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

示例1: test_withChronology

import java.time.format.DateTimeFormatter; //导入方法依赖的package包/类
@Test
public void test_withChronology() {
    DateTimeFormatter test = fmt;
    assertEquals(test.getChronology(), null);
    test = test.withChronology(IsoChronology.INSTANCE);
    assertEquals(test.getChronology(), IsoChronology.INSTANCE);
    test = test.withChronology(null);
    assertEquals(test.getChronology(), null);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:10,代码来源:TCKDateTimeFormatter.java

示例2: test_withChronology_override

import java.time.format.DateTimeFormatter; //导入方法依赖的package包/类
@Test
public void test_withChronology_override() {
    DateTimeFormatter f = new DateTimeFormatterBuilder().parseDefaulting(EPOCH_DAY, 2).toFormatter();
    f = f.withChronology(MinguoChronology.INSTANCE);
    TemporalAccessor accessor = f.parse("");
    assertEquals(accessor.query(TemporalQueries.localDate()), LocalDate.of(1970, 1, 3));
    assertEquals(accessor.query(TemporalQueries.localTime()), null);
    assertEquals(accessor.query(TemporalQueries.chronology()), MinguoChronology.INSTANCE);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:10,代码来源:TCKDateTimeParseResolver.java

示例3: test_withChronology_parsedChronology_override

import java.time.format.DateTimeFormatter; //导入方法依赖的package包/类
@Test
public void test_withChronology_parsedChronology_override() {
    DateTimeFormatter f = new DateTimeFormatterBuilder().parseDefaulting(EPOCH_DAY, 2).appendChronologyId().toFormatter();
    f = f.withChronology(MinguoChronology.INSTANCE);
    TemporalAccessor accessor = f.parse("ThaiBuddhist");
    assertEquals(accessor.query(TemporalQueries.localDate()), LocalDate.of(1970, 1, 3));
    assertEquals(accessor.query(TemporalQueries.localTime()), null);
    assertEquals(accessor.query(TemporalQueries.chronology()), ThaiBuddhistChronology.INSTANCE);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:10,代码来源:TCKDateTimeParseResolver.java

示例4: test_fieldResolvesToChronoLocalDate_overrideChrono_matches

import java.time.format.DateTimeFormatter; //导入方法依赖的package包/类
@Test
public void test_fieldResolvesToChronoLocalDate_overrideChrono_matches() {
    MinguoDate mdt = MinguoDate.of(100, 6, 30);
    DateTimeFormatter f = new DateTimeFormatterBuilder().appendValue(new ResolvingField(mdt)).toFormatter();
    f = f.withChronology(MinguoChronology.INSTANCE);
    TemporalAccessor accessor = f.parse("1234567890");
    assertEquals(accessor.query(TemporalQueries.localDate()), LocalDate.from(mdt));
    assertEquals(accessor.query(TemporalQueries.localTime()), null);
    assertEquals(accessor.query(TemporalQueries.chronology()), MinguoChronology.INSTANCE);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:11,代码来源:TCKDateTimeParseResolver.java

示例5: test_fieldResolvesToChronoLocalDate_overrideChrono_wrongChrono

import java.time.format.DateTimeFormatter; //导入方法依赖的package包/类
@Test(expectedExceptions = DateTimeParseException.class)
public void test_fieldResolvesToChronoLocalDate_overrideChrono_wrongChrono() {
    ChronoLocalDate cld = ThaiBuddhistChronology.INSTANCE.dateNow();
    DateTimeFormatter f = new DateTimeFormatterBuilder().appendValue(new ResolvingField(cld)).toFormatter();
    f = f.withChronology(MinguoChronology.INSTANCE);
    f.parse("1234567890");
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:8,代码来源:TCKDateTimeParseResolver.java

示例6: test_fieldResolvesToChronoLocalDateTime_overrideChrono_matches

import java.time.format.DateTimeFormatter; //导入方法依赖的package包/类
@Test
public void test_fieldResolvesToChronoLocalDateTime_overrideChrono_matches() {
    MinguoDate mdt = MinguoDate.of(100, 6, 30);
    DateTimeFormatter f = new DateTimeFormatterBuilder().appendValue(new ResolvingField(mdt.atTime(LocalTime.NOON))).toFormatter();
    f = f.withChronology(MinguoChronology.INSTANCE);
    TemporalAccessor accessor = f.parse("1234567890");
    assertEquals(accessor.query(TemporalQueries.localDate()), LocalDate.from(mdt));
    assertEquals(accessor.query(TemporalQueries.localTime()), LocalTime.NOON);
    assertEquals(accessor.query(TemporalQueries.chronology()), MinguoChronology.INSTANCE);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:11,代码来源:TCKDateTimeParseResolver.java

示例7: test_fieldResolvesToChronoLocalDateTime_overrideChrono_wrongChrono

import java.time.format.DateTimeFormatter; //导入方法依赖的package包/类
@Test(expectedExceptions = DateTimeParseException.class)
public void test_fieldResolvesToChronoLocalDateTime_overrideChrono_wrongChrono() {
    ChronoLocalDateTime<?> cldt = ThaiBuddhistChronology.INSTANCE.dateNow().atTime(LocalTime.NOON);
    DateTimeFormatter f = new DateTimeFormatterBuilder().appendValue(new ResolvingField(cldt)).toFormatter();
    f = f.withChronology(MinguoChronology.INSTANCE);
    f.parse("1234567890");
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:8,代码来源:TCKDateTimeParseResolver.java

示例8: test_fieldResolvesToChronoZonedDateTime_overrideChrono_matches

import java.time.format.DateTimeFormatter; //导入方法依赖的package包/类
@Test
public void test_fieldResolvesToChronoZonedDateTime_overrideChrono_matches() {
    MinguoDate mdt = MinguoDate.of(100, 6, 30);
    ChronoZonedDateTime<MinguoDate> mzdt = mdt.atTime(LocalTime.NOON).atZone(EUROPE_PARIS);
    DateTimeFormatter f = new DateTimeFormatterBuilder().appendValue(new ResolvingField(mzdt)).toFormatter();
    f = f.withChronology(MinguoChronology.INSTANCE);
    TemporalAccessor accessor = f.parse("1234567890");
    assertEquals(accessor.query(TemporalQueries.localDate()), LocalDate.from(mdt));
    assertEquals(accessor.query(TemporalQueries.localTime()), LocalTime.NOON);
    assertEquals(accessor.query(TemporalQueries.chronology()), MinguoChronology.INSTANCE);
    assertEquals(accessor.query(TemporalQueries.zoneId()), EUROPE_PARIS);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:13,代码来源:TCKDateTimeParseResolver.java

示例9: test_fieldResolvesToChronoZonedDateTime_overrideChrono_wrongChrono

import java.time.format.DateTimeFormatter; //导入方法依赖的package包/类
@Test(expectedExceptions = DateTimeParseException.class)
public void test_fieldResolvesToChronoZonedDateTime_overrideChrono_wrongChrono() {
    ChronoZonedDateTime<?> cldt = ThaiBuddhistChronology.INSTANCE.dateNow().atTime(LocalTime.NOON).atZone(EUROPE_PARIS);
    DateTimeFormatter f = new DateTimeFormatterBuilder().appendValue(new ResolvingField(cldt)).toFormatter();
    f = f.withChronology(MinguoChronology.INSTANCE);
    f.parse("1234567890");
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:8,代码来源:TCKDateTimeParseResolver.java


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