本文整理汇总了Java中java.time.chrono.MinguoDate类的典型用法代码示例。如果您正苦于以下问题:Java MinguoDate类的具体用法?Java MinguoDate怎么用?Java MinguoDate使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MinguoDate类属于java.time.chrono包,在下文中一共展示了MinguoDate类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: test_MinguoDate
import java.time.chrono.MinguoDate; //导入依赖的package包/类
@SuppressWarnings("unused")
@Test(dataProvider="samples")
public void test_MinguoDate(MinguoDate minguoDate, LocalDate iso) {
MinguoDate hd = minguoDate;
ChronoLocalDateTime<MinguoDate> hdt = hd.atTime(LocalTime.NOON);
ZoneOffset zo = ZoneOffset.ofHours(1);
ChronoZonedDateTime<MinguoDate> hzdt = hdt.atZone(zo);
hdt = hdt.plus(1, ChronoUnit.YEARS);
hdt = hdt.plus(1, ChronoUnit.MONTHS);
hdt = hdt.plus(1, ChronoUnit.DAYS);
hdt = hdt.plus(1, ChronoUnit.HOURS);
hdt = hdt.plus(1, ChronoUnit.MINUTES);
hdt = hdt.plus(1, ChronoUnit.SECONDS);
hdt = hdt.plus(1, ChronoUnit.NANOS);
ChronoLocalDateTime<MinguoDate> a2 = hzdt.toLocalDateTime();
MinguoDate a3 = a2.toLocalDate();
MinguoDate a5 = hzdt.toLocalDate();
//System.out.printf(" d: %s, dt: %s; odt: %s; zodt: %s; a4: %s%n", date, hdt, hodt, hzdt, a5);
}
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:20,代码来源:TCKMinguoChronology.java
示例2: test_dateNow
import java.time.chrono.MinguoDate; //导入依赖的package包/类
@Test
public void test_dateNow(){
assertEquals(MinguoChronology.INSTANCE.dateNow(), MinguoDate.now()) ;
assertEquals(MinguoChronology.INSTANCE.dateNow(), MinguoDate.now(ZoneId.systemDefault())) ;
assertEquals(MinguoChronology.INSTANCE.dateNow(), MinguoDate.now(Clock.systemDefaultZone())) ;
assertEquals(MinguoChronology.INSTANCE.dateNow(), MinguoDate.now(Clock.systemDefaultZone().getZone())) ;
assertEquals(MinguoChronology.INSTANCE.dateNow(), MinguoChronology.INSTANCE.dateNow(ZoneId.systemDefault())) ;
assertEquals(MinguoChronology.INSTANCE.dateNow(), MinguoChronology.INSTANCE.dateNow(Clock.systemDefaultZone())) ;
assertEquals(MinguoChronology.INSTANCE.dateNow(), MinguoChronology.INSTANCE.dateNow(Clock.systemDefaultZone().getZone())) ;
ZoneId zoneId = ZoneId.of("Europe/Paris");
assertEquals(MinguoChronology.INSTANCE.dateNow(zoneId), MinguoChronology.INSTANCE.dateNow(Clock.system(zoneId))) ;
assertEquals(MinguoChronology.INSTANCE.dateNow(zoneId), MinguoChronology.INSTANCE.dateNow(Clock.system(zoneId).getZone())) ;
assertEquals(MinguoChronology.INSTANCE.dateNow(zoneId), MinguoDate.now(Clock.system(zoneId))) ;
assertEquals(MinguoChronology.INSTANCE.dateNow(zoneId), MinguoDate.now(Clock.system(zoneId).getZone())) ;
assertEquals(MinguoChronology.INSTANCE.dateNow(ZoneId.of(ZoneOffset.UTC.getId())), MinguoChronology.INSTANCE.dateNow(Clock.systemUTC())) ;
}
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:20,代码来源:TCKMinguoChronology.java
示例3: test_resolve_yearOfEra
import java.time.chrono.MinguoDate; //导入依赖的package包/类
@Test(dataProvider = "resolve_yearOfEra")
public void test_resolve_yearOfEra(ResolverStyle style, Integer e, Integer yoe, Integer y, ChronoField field, Integer expected) {
Map<TemporalField, Long> fieldValues = new HashMap<>();
if (e != null) {
fieldValues.put(ChronoField.ERA, (long) e);
}
if (yoe != null) {
fieldValues.put(ChronoField.YEAR_OF_ERA, (long) yoe);
}
if (y != null) {
fieldValues.put(ChronoField.YEAR, (long) y);
}
if (field != null) {
MinguoDate date = MinguoChronology.INSTANCE.resolveDate(fieldValues, style);
assertEquals(date, null);
assertEquals(fieldValues.get(field), (Long) expected.longValue());
assertEquals(fieldValues.size(), 1);
} else {
try {
MinguoChronology.INSTANCE.resolveDate(fieldValues, style);
fail("Should have failed");
} catch (DateTimeException ex) {
// expected
}
}
}
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:27,代码来源:TCKMinguoChronology.java
示例4: test_resolve_ymd_strict
import java.time.chrono.MinguoDate; //导入依赖的package包/类
@Test(dataProvider = "resolve_ymd")
public void test_resolve_ymd_strict(int y, int m, int d, MinguoDate expected, Object smart, boolean strict) {
Map<TemporalField, Long> fieldValues = new HashMap<>();
fieldValues.put(ChronoField.YEAR, (long) y);
fieldValues.put(ChronoField.MONTH_OF_YEAR, (long) m);
fieldValues.put(ChronoField.DAY_OF_MONTH, (long) d);
if (strict) {
MinguoDate date = MinguoChronology.INSTANCE.resolveDate(fieldValues, ResolverStyle.STRICT);
assertEquals(date, expected);
assertEquals(fieldValues.size(), 0);
} else {
try {
MinguoChronology.INSTANCE.resolveDate(fieldValues, ResolverStyle.STRICT);
fail("Should have failed");
} catch (DateTimeException ex) {
// expected
}
}
}
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:20,代码来源:TCKMinguoChronology.java
示例5: test_resolve_yd_smart
import java.time.chrono.MinguoDate; //导入依赖的package包/类
@Test(dataProvider = "resolve_yd")
public void test_resolve_yd_smart(int y, int d, MinguoDate expected, boolean smart, boolean strict) {
Map<TemporalField, Long> fieldValues = new HashMap<>();
fieldValues.put(ChronoField.YEAR, (long) y);
fieldValues.put(ChronoField.DAY_OF_YEAR, (long) d);
if (smart) {
MinguoDate date = MinguoChronology.INSTANCE.resolveDate(fieldValues, ResolverStyle.SMART);
assertEquals(date, expected);
assertEquals(fieldValues.size(), 0);
} else {
try {
MinguoChronology.INSTANCE.resolveDate(fieldValues, ResolverStyle.SMART);
fail("Should have failed");
} catch (DateTimeException ex) {
// expected
}
}
}
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:19,代码来源:TCKMinguoChronology.java
示例6: test_resolve_yd_strict
import java.time.chrono.MinguoDate; //导入依赖的package包/类
@Test(dataProvider = "resolve_yd")
public void test_resolve_yd_strict(int y, int d, MinguoDate expected, boolean smart, boolean strict) {
Map<TemporalField, Long> fieldValues = new HashMap<>();
fieldValues.put(ChronoField.YEAR, (long) y);
fieldValues.put(ChronoField.DAY_OF_YEAR, (long) d);
if (strict) {
MinguoDate date = MinguoChronology.INSTANCE.resolveDate(fieldValues, ResolverStyle.STRICT);
assertEquals(date, expected);
assertEquals(fieldValues.size(), 0);
} else {
try {
MinguoChronology.INSTANCE.resolveDate(fieldValues, ResolverStyle.STRICT);
fail("Should have failed");
} catch (DateTimeException ex) {
// expected
}
}
}
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:19,代码来源:TCKMinguoChronology.java
示例7: test_resolve_ymaa_smart
import java.time.chrono.MinguoDate; //导入依赖的package包/类
@Test(dataProvider = "resolve_ymaa")
public void test_resolve_ymaa_smart(int y, int m, int w, int d, MinguoDate expected, boolean smart, boolean strict) {
Map<TemporalField, Long> fieldValues = new HashMap<>();
fieldValues.put(ChronoField.YEAR, (long) y);
fieldValues.put(ChronoField.MONTH_OF_YEAR, (long) m);
fieldValues.put(ChronoField.ALIGNED_WEEK_OF_MONTH, (long) w);
fieldValues.put(ChronoField.ALIGNED_DAY_OF_WEEK_IN_MONTH, (long) d);
if (smart) {
MinguoDate date = MinguoChronology.INSTANCE.resolveDate(fieldValues, ResolverStyle.SMART);
assertEquals(date, expected);
assertEquals(fieldValues.size(), 0);
} else {
try {
MinguoChronology.INSTANCE.resolveDate(fieldValues, ResolverStyle.SMART);
fail("Should have failed");
} catch (DateTimeException ex) {
// expected
}
}
}
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:21,代码来源:TCKMinguoChronology.java
示例8: test_resolve_ymaa_strict
import java.time.chrono.MinguoDate; //导入依赖的package包/类
@Test(dataProvider = "resolve_ymaa")
public void test_resolve_ymaa_strict(int y, int m, int w, int d, MinguoDate expected, boolean smart, boolean strict) {
Map<TemporalField, Long> fieldValues = new HashMap<>();
fieldValues.put(ChronoField.YEAR, (long) y);
fieldValues.put(ChronoField.MONTH_OF_YEAR, (long) m);
fieldValues.put(ChronoField.ALIGNED_WEEK_OF_MONTH, (long) w);
fieldValues.put(ChronoField.ALIGNED_DAY_OF_WEEK_IN_MONTH, (long) d);
if (strict) {
MinguoDate date = MinguoChronology.INSTANCE.resolveDate(fieldValues, ResolverStyle.STRICT);
assertEquals(date, expected);
assertEquals(fieldValues.size(), 0);
} else {
try {
MinguoChronology.INSTANCE.resolveDate(fieldValues, ResolverStyle.STRICT);
fail("Should have failed");
} catch (DateTimeException ex) {
// expected
}
}
}
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:21,代码来源:TCKMinguoChronology.java
示例9: test_minguoChrono_fixedWidth
import java.time.chrono.MinguoDate; //导入依赖的package包/类
public void test_minguoChrono_fixedWidth() throws Exception {
// ISO 2021 is Minguo 110
DateTimeFormatter f = getFormatterBaseDate(YEAR, 2, 2, 2021);
MinguoDate date = MinguoDate.of(109, 6, 30);
assertEquals(f.format(date), "09");
date = MinguoDate.of(110, 6, 30);
assertEquals(f.format(date), "10");
date = MinguoDate.of(199, 6, 30);
assertEquals(f.format(date), "99");
date = MinguoDate.of(200, 6, 30);
assertEquals(f.format(date), "00");
date = MinguoDate.of(209, 6, 30);
assertEquals(f.format(date), "09");
date = MinguoDate.of(210, 6, 30);
assertEquals(f.format(date), "10");
}
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:17,代码来源:TestReducedPrinter.java
示例10: test_minguoChrono_extendedWidth
import java.time.chrono.MinguoDate; //导入依赖的package包/类
public void test_minguoChrono_extendedWidth() throws Exception {
// ISO 2021 is Minguo 110
DateTimeFormatter f = getFormatterBaseDate(YEAR, 2, 4, 2021);
MinguoDate date = MinguoDate.of(109, 6, 30);
assertEquals(f.format(date), "109");
date = MinguoDate.of(110, 6, 30);
assertEquals(f.format(date), "10");
date = MinguoDate.of(199, 6, 30);
assertEquals(f.format(date), "99");
date = MinguoDate.of(200, 6, 30);
assertEquals(f.format(date), "00");
date = MinguoDate.of(209, 6, 30);
assertEquals(f.format(date), "09");
date = MinguoDate.of(210, 6, 30);
assertEquals(f.format(date), "210");
}
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:17,代码来源:TestReducedPrinter.java
注:本文中的java.time.chrono.MinguoDate类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论