本文整理汇总了Java中java.time.chrono.MinguoChronology类的典型用法代码示例。如果您正苦于以下问题:Java MinguoChronology类的具体用法?Java MinguoChronology怎么用?Java MinguoChronology使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MinguoChronology类属于java.time.chrono包,在下文中一共展示了MinguoChronology类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: provider_reducedWithChrono
import java.time.chrono.MinguoChronology; //导入依赖的package包/类
@DataProvider(name="ReducedWithChrono")
Object[][] provider_reducedWithChrono() {
LocalDate baseYear = LocalDate.of(2000, 1, 1);
return new Object[][] {
{IsoChronology.INSTANCE.date(baseYear)},
{IsoChronology.INSTANCE.date(baseYear).plus(1, YEARS)},
{IsoChronology.INSTANCE.date(baseYear).plus(99, YEARS)},
{HijrahChronology.INSTANCE.date(baseYear)},
{HijrahChronology.INSTANCE.date(baseYear).plus(1, YEARS)},
{HijrahChronology.INSTANCE.date(baseYear).plus(99, YEARS)},
{JapaneseChronology.INSTANCE.date(baseYear)},
{JapaneseChronology.INSTANCE.date(baseYear).plus(1, YEARS)},
{JapaneseChronology.INSTANCE.date(baseYear).plus(99, YEARS)},
{MinguoChronology.INSTANCE.date(baseYear)},
{MinguoChronology.INSTANCE.date(baseYear).plus(1, YEARS)},
{MinguoChronology.INSTANCE.date(baseYear).plus(99, YEARS)},
{ThaiBuddhistChronology.INSTANCE.date(baseYear)},
{ThaiBuddhistChronology.INSTANCE.date(baseYear).plus(1, YEARS)},
{ThaiBuddhistChronology.INSTANCE.date(baseYear).plus(99, YEARS)},
};
}
示例2: test_dateNow
import java.time.chrono.MinguoChronology; //导入依赖的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())) ;
}
示例3: test_resolve_yearOfEra
import java.time.chrono.MinguoChronology; //导入依赖的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
}
}
}
示例4: test_resolve_ymd_strict
import java.time.chrono.MinguoChronology; //导入依赖的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
}
}
}
示例5: test_resolve_yd_smart
import java.time.chrono.MinguoChronology; //导入依赖的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
}
}
}
示例6: test_resolve_yd_strict
import java.time.chrono.MinguoChronology; //导入依赖的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
}
}
}
示例7: test_resolve_ymaa_smart
import java.time.chrono.MinguoChronology; //导入依赖的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
}
}
}
示例8: test_resolve_ymaa_strict
import java.time.chrono.MinguoChronology; //导入依赖的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
}
}
}
示例9: data_epochSecond
import java.time.chrono.MinguoChronology; //导入依赖的package包/类
@DataProvider(name = "epochSecond_dataProvider")
Object[][] data_epochSecond() {
return new Object[][] {
{JapaneseChronology.INSTANCE, 1873, 9, 7, 1, 2, 2, OFFSET_P0100},
{JapaneseChronology.INSTANCE, 1928, 2, 28, 1, 2, 2, OFFSET_M0100},
{JapaneseChronology.INSTANCE, 1989, 1, 8, 1, 2, 2, OFFSET_P0100},
{HijrahChronology.INSTANCE, 1434, 9, 7, 1, 2, 2, OFFSET_P0100},
{MinguoChronology.INSTANCE, 1873, 9, 7, 1, 2, 2, OFFSET_P0100},
{MinguoChronology.INSTANCE, 1928, 2, 28, 1, 2, 2, OFFSET_M0100},
{MinguoChronology.INSTANCE, 1989, 1, 8, 1, 2, 2, OFFSET_P0100},
{ThaiBuddhistChronology.INSTANCE, 1873, 9, 7, 1, 2, 2, OFFSET_P0100},
{ThaiBuddhistChronology.INSTANCE, 1928, 2, 28, 1, 2, 2, OFFSET_M0100},
{ThaiBuddhistChronology.INSTANCE, 1989, 1, 8, 1, 2, 2, OFFSET_P0100},
{IsoChronology.INSTANCE, 1873, 9, 7, 1, 2, 2, OFFSET_P0100},
{IsoChronology.INSTANCE, 1928, 2, 28, 1, 2, 2, OFFSET_M0100},
{IsoChronology.INSTANCE, 1989, 1, 8, 1, 2, 2, OFFSET_P0100},
};
}
示例10: data_era_epochSecond
import java.time.chrono.MinguoChronology; //导入依赖的package包/类
@DataProvider(name = "era_epochSecond_dataProvider")
Object[][] data_era_epochSecond() {
return new Object[][] {
{JapaneseChronology.INSTANCE, JapaneseEra.MEIJI, 1873 - YDIFF_MEIJI, 9, 7, 1, 2, 2, OFFSET_P0100},
{JapaneseChronology.INSTANCE, JapaneseEra.SHOWA, 1928 - YDIFF_SHOWA, 2, 28, 1, 2, 2, OFFSET_M0100},
{JapaneseChronology.INSTANCE, JapaneseEra.HEISEI, 1989 - YDIFF_HEISEI, 1, 8, 1, 2, 2, OFFSET_P0100},
{HijrahChronology.INSTANCE, HijrahEra.AH, 1434, 9, 7, 1, 2, 2, OFFSET_P0100},
{MinguoChronology.INSTANCE, MinguoEra.BEFORE_ROC, 1873 - YDIFF_MINGUO, 9, 7, 1, 2, 2, OFFSET_P0100},
{MinguoChronology.INSTANCE, MinguoEra.ROC, 1928 - YDIFF_MINGUO, 2, 28, 1, 2, 2, OFFSET_M0100},
{MinguoChronology.INSTANCE, MinguoEra.ROC, 1989 - YDIFF_MINGUO, 1, 8, 1, 2, 2, OFFSET_P0100},
{ThaiBuddhistChronology.INSTANCE, ThaiBuddhistEra.BE, 1873 + YDIFF_THAIBUDDHIST, 9, 7, 1, 2, 2, OFFSET_P0100},
{ThaiBuddhistChronology.INSTANCE, ThaiBuddhistEra.BE, 1928 + YDIFF_THAIBUDDHIST, 2, 28, 1, 2, 2, OFFSET_M0100},
{ThaiBuddhistChronology.INSTANCE, ThaiBuddhistEra.BE, 1989 + YDIFF_THAIBUDDHIST, 1, 8, 1, 2, 2, OFFSET_P0100},
{IsoChronology.INSTANCE, IsoEra.CE, 1873, 9, 7, 1, 2, 2, OFFSET_P0100},
{IsoChronology.INSTANCE, IsoEra.CE, 1928, 2, 28, 1, 2, 2, OFFSET_M0100},
{IsoChronology.INSTANCE, IsoEra.CE, 1989, 1, 8, 1, 2, 2, OFFSET_P0100},
};
}
示例11: test_withChronology_override
import java.time.chrono.MinguoChronology; //导入依赖的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);
}
示例12: test_withChronology_parsedChronology_override
import java.time.chrono.MinguoChronology; //导入依赖的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);
}
示例13: test_fieldResolvesToChronoLocalDate_overrideChrono_matches
import java.time.chrono.MinguoChronology; //导入依赖的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);
}
示例14: data_of_calendars
import java.time.chrono.MinguoChronology; //导入依赖的package包/类
@DataProvider(name = "calendars")
Chronology[][] data_of_calendars() {
return new Chronology[][]{
{HijrahChronology.INSTANCE},
{IsoChronology.INSTANCE},
{JapaneseChronology.INSTANCE},
{MinguoChronology.INSTANCE},
{ThaiBuddhistChronology.INSTANCE}};
}
示例15: test_fieldResolvesToChronoLocalDateTime_overrideChrono_matches
import java.time.chrono.MinguoChronology; //导入依赖的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);
}