本文整理汇总了Java中java.time.chrono.HijrahDate类的典型用法代码示例。如果您正苦于以下问题:Java HijrahDate类的具体用法?Java HijrahDate怎么用?Java HijrahDate使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
HijrahDate类属于java.time.chrono包,在下文中一共展示了HijrahDate类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: test_dateNow
import java.time.chrono.HijrahDate; //导入依赖的package包/类
@Test
public void test_dateNow(){
assertEquals(HijrahChronology.INSTANCE.dateNow(), HijrahDate.now()) ;
assertEquals(HijrahChronology.INSTANCE.dateNow(), HijrahDate.now(ZoneId.systemDefault())) ;
assertEquals(HijrahChronology.INSTANCE.dateNow(), HijrahDate.now(Clock.systemDefaultZone())) ;
assertEquals(HijrahChronology.INSTANCE.dateNow(), HijrahDate.now(Clock.systemDefaultZone().getZone())) ;
assertEquals(HijrahChronology.INSTANCE.dateNow(), HijrahChronology.INSTANCE.dateNow(ZoneId.systemDefault())) ;
assertEquals(HijrahChronology.INSTANCE.dateNow(), HijrahChronology.INSTANCE.dateNow(Clock.systemDefaultZone())) ;
assertEquals(HijrahChronology.INSTANCE.dateNow(), HijrahChronology.INSTANCE.dateNow(Clock.systemDefaultZone().getZone())) ;
ZoneId zoneId = ZoneId.of("Europe/Paris");
assertEquals(HijrahChronology.INSTANCE.dateNow(zoneId), HijrahChronology.INSTANCE.dateNow(Clock.system(zoneId))) ;
assertEquals(HijrahChronology.INSTANCE.dateNow(zoneId), HijrahChronology.INSTANCE.dateNow(Clock.system(zoneId).getZone())) ;
assertEquals(HijrahChronology.INSTANCE.dateNow(zoneId), HijrahDate.now(Clock.system(zoneId))) ;
assertEquals(HijrahChronology.INSTANCE.dateNow(zoneId), HijrahDate.now(Clock.system(zoneId).getZone())) ;
assertEquals(HijrahChronology.INSTANCE.dateNow(ZoneId.of(ZoneOffset.UTC.getId())), HijrahChronology.INSTANCE.dateNow(Clock.systemUTC())) ;
}
示例2: test_resolve_yearOfEra_eraOnly_valid
import java.time.chrono.HijrahDate; //导入依赖的package包/类
@Test(dataProvider = "resolve_styleByEra")
public void test_resolve_yearOfEra_eraOnly_valid(ResolverStyle style, HijrahEra era) {
Map<TemporalField, Long> fieldValues = new HashMap<>();
fieldValues.put(ChronoField.ERA, (long) era.getValue());
HijrahDate date = HijrahChronology.INSTANCE.resolveDate(fieldValues, style);
assertEquals(date, null);
assertEquals(fieldValues.get(ChronoField.ERA), (Long) (long) era.getValue());
assertEquals(fieldValues.size(), 1);
}
示例3: test_resolve_yearOfEra_eraAndYearOfEraOnly_valid
import java.time.chrono.HijrahDate; //导入依赖的package包/类
@Test(dataProvider = "resolve_styleByEra")
public void test_resolve_yearOfEra_eraAndYearOfEraOnly_valid(ResolverStyle style, HijrahEra era) {
Map<TemporalField, Long> fieldValues = new HashMap<>();
fieldValues.put(ChronoField.ERA, (long) era.getValue());
fieldValues.put(ChronoField.YEAR_OF_ERA, 1343L);
HijrahDate date = HijrahChronology.INSTANCE.resolveDate(fieldValues, style);
assertEquals(date, null);
assertEquals(fieldValues.get(ChronoField.ERA), null);
assertEquals(fieldValues.get(ChronoField.YEAR_OF_ERA), null);
assertEquals(fieldValues.get(ChronoField.YEAR), (Long) 1343L);
assertEquals(fieldValues.size(), 1);
}
示例4: test_resolve_yearOfEra_eraAndYearOnly_valid
import java.time.chrono.HijrahDate; //导入依赖的package包/类
@Test(dataProvider = "resolve_styleByEra")
public void test_resolve_yearOfEra_eraAndYearOnly_valid(ResolverStyle style, HijrahEra era) {
Map<TemporalField, Long> fieldValues = new HashMap<>();
fieldValues.put(ChronoField.ERA, (long) era.getValue());
fieldValues.put(ChronoField.YEAR, 1343L);
HijrahDate date = HijrahChronology.INSTANCE.resolveDate(fieldValues, style);
assertEquals(date, null);
assertEquals(fieldValues.get(ChronoField.ERA), (Long) (long) era.getValue());
assertEquals(fieldValues.get(ChronoField.YEAR), (Long) 1343L);
assertEquals(fieldValues.size(), 2);
}
示例5: test_resolve_yearOfEra_yearOfEraOnly_valid
import java.time.chrono.HijrahDate; //导入依赖的package包/类
@Test(dataProvider = "resolve_styles")
public void test_resolve_yearOfEra_yearOfEraOnly_valid(ResolverStyle style) {
Map<TemporalField, Long> fieldValues = new HashMap<>();
fieldValues.put(ChronoField.YEAR_OF_ERA, 1343L);
HijrahDate date = HijrahChronology.INSTANCE.resolveDate(fieldValues, style);
assertEquals(date, null);
assertEquals(fieldValues.get(ChronoField.YEAR_OF_ERA), (style != ResolverStyle.STRICT) ? null : (Long) 1343L);
assertEquals(fieldValues.get(ChronoField.YEAR), (style == ResolverStyle.STRICT) ? null : (Long) 1343L);
assertEquals(fieldValues.size(), 1);
}
示例6: test_resolve_yearOfEra_yearOfEraAndYearOnly_valid
import java.time.chrono.HijrahDate; //导入依赖的package包/类
@Test(dataProvider = "resolve_styles")
public void test_resolve_yearOfEra_yearOfEraAndYearOnly_valid(ResolverStyle style) {
Map<TemporalField, Long> fieldValues = new HashMap<>();
fieldValues.put(ChronoField.YEAR_OF_ERA, 1343L);
fieldValues.put(ChronoField.YEAR, 1343L);
HijrahDate date = HijrahChronology.INSTANCE.resolveDate(fieldValues, style);
assertEquals(date, null);
assertEquals(fieldValues.get(ChronoField.YEAR_OF_ERA), null);
assertEquals(fieldValues.get(ChronoField.YEAR), (Long) 1343L);
assertEquals(fieldValues.size(), 1);
}
示例7: test_resolve_yd_lenient
import java.time.chrono.HijrahDate; //导入依赖的package包/类
@Test(dataProvider = "resolve_yd")
public void test_resolve_yd_lenient(int y, int d, HijrahDate 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);
HijrahDate date = HijrahChronology.INSTANCE.resolveDate(fieldValues, ResolverStyle.LENIENT);
assertEquals(date, expected);
assertEquals(fieldValues.size(), 0);
}
示例8: invalid_serial_classes
import java.time.chrono.HijrahDate; //导入依赖的package包/类
@DataProvider(name = "invalidSerialformClasses")
Object[][] invalid_serial_classes() {
return new Object[][]{
{JapaneseEra.class},
{JapaneseDate.class},
{MinguoDate.class},
{ThaiBuddhistDate.class},
{HijrahDate.class},
};
}
示例9: HijrahExample1
import java.time.chrono.HijrahDate; //导入依赖的package包/类
void HijrahExample1() {
HijrahDate hd2 = HijrahChronology.INSTANCE.date(1200, 1, 1);
ChronoLocalDateTime<HijrahDate> hdt = hd2.atTime(LocalTime.MIDNIGHT);
ChronoZonedDateTime<HijrahDate> zhdt = hdt.atZone(ZoneId.of("GMT"));
HijrahDate hd3 = zhdt.toLocalDate();
ChronoLocalDateTime<HijrahDate> hdt2 = zhdt.toLocalDateTime();
HijrahDate hd4 = hdt2.toLocalDate();
HijrahDate hd5 = next(hd2);
}
示例10: test_library
import java.time.chrono.HijrahDate; //导入依赖的package包/类
@Test
public void test_library() {
HijrahDate date = HijrahDate.now();
HijrahDate next = next(date);
ChronoLocalDateTime<HijrahDate> noonTomorrow = tomorrowNoon(date);
HijrahDate hd3 = noonTomorrow.toLocalDate();
System.out.printf(" now: %s, noon tomorrow: %s%n", date, noonTomorrow);
}
示例11: data_UmmAlQuraVsISODates
import java.time.chrono.HijrahDate; //导入依赖的package包/类
@DataProvider(name = "UmmAlQuraVsISODates")
Object[][] data_UmmAlQuraVsISODates() {
return new Object[][] {
{HijrahDate.of(1318, 1, 1), LocalDate.of(1900, 04, 30)},
{HijrahDate.of(1318, 12, 29), LocalDate.of(1901, 04, 19)},
{HijrahDate.of(1319, 01, 01), LocalDate.of(1901, 04, 20)},
{HijrahDate.of(1433, 12, 29), LocalDate.of(2012, 11, 14)},
{HijrahDate.of(1434, 01, 01), LocalDate.of(2012, 11, 15)},
{HijrahDate.of(1434, 02, 18), LocalDate.of(2012, 12, 31)},
{HijrahDate.of(1502, 12, 29), LocalDate.of(2079, 10, 25)},
};
}
示例12: data_dates
import java.time.chrono.HijrahDate; //导入依赖的package包/类
@DataProvider(name = "dates")
Object[][] data_dates() {
return new Object[][]{
{HijrahDate.of(1300, 5, 1), 1300, 1600, 1, 12, 1, 30, 30},
{HijrahDate.of(1300, 6, 1), 1300, 1600, 1, 12, 1, 29, 30},
{HijrahDate.of(1434, 12, 1), 1300, 1600, 1, 12, 1, 29, 30},
{HijrahDate.of(1500, 4, 1), 1300, 1600, 1, 12, 1, 30, 30},
{HijrahDate.of(1600, 6, 1), 1300, 1600, 1, 12, 1, 29, 30},
};
}
示例13: Test_UmmAlQuraRanges
import java.time.chrono.HijrahDate; //导入依赖的package包/类
@Test(dataProvider="dates")
public void Test_UmmAlQuraRanges(HijrahDate date,
int minYear, int maxYear,
int minMonth, int maxMonth,
int minDay, int maxDay, int maxChronoDay) {
// Check the chronology ranges
HijrahChronology chrono = date.getChronology();
ValueRange yearRange = chrono.range(YEAR);
assertEquals(yearRange.getMinimum(), minYear, "Minimum year for Hijrah chronology");
assertEquals(yearRange.getLargestMinimum(), minYear, "Largest minimum year for Hijrah chronology");
assertEquals(yearRange.getMaximum(), maxYear, "Maximum year for Hijrah chronology");
assertEquals(yearRange.getSmallestMaximum(), maxYear, "Smallest Maximum year for Hijrah chronology");
ValueRange monthRange = chrono.range(MONTH_OF_YEAR);
assertEquals(monthRange.getMinimum(), minMonth, "Minimum month for Hijrah chronology");
assertEquals(monthRange.getMaximum(), maxMonth, "Maximum month for Hijrah chronology");
ValueRange daysRange = chrono.range(DAY_OF_MONTH);
assertEquals(daysRange.getMinimum(), minDay, "Minimum day for chronology");
assertEquals(daysRange.getMaximum(), maxChronoDay, "Maximum day for Hijrah chronology");
// Check the date ranges
yearRange = date.range(YEAR);
assertEquals(yearRange.getMinimum(), minYear, "Minimum year for Hijrah date");
assertEquals(yearRange.getLargestMinimum(), minYear, "Largest minimum year for Hijrah date");
assertEquals(yearRange.getMaximum(), maxYear, "Maximum year for Hijrah date");
assertEquals(yearRange.getSmallestMaximum(), maxYear, "Smallest maximum year for Hijrah date");
monthRange = date.range(MONTH_OF_YEAR);
assertEquals(monthRange.getMinimum(), minMonth, "Minimum month for HijrahDate");
assertEquals(monthRange.getMaximum(), maxMonth, "Maximum month for HijrahDate");
daysRange = date.range(DAY_OF_MONTH);
assertEquals(daysRange.getMinimum(), minDay, "Minimum day for HijrahDate");
assertEquals(daysRange.getMaximum(), maxDay, "Maximum day for HijrahDate");
}
示例14: test_getDayOfYear
import java.time.chrono.HijrahDate; //导入依赖的package包/类
@Test
public void test_getDayOfYear() {
HijrahDate hd1 = HijrahChronology.INSTANCE.dateYearDay(1434, 1);
for (int i = 1; i <= hd1.lengthOfYear(); i++) {
HijrahDate hd = HijrahChronology.INSTANCE.dateYearDay(1434, i);
int doy = hd.get(DAY_OF_YEAR);
assertEquals(doy, i, "get(DAY_OF_YEAR) incorrect for " + i);
}
}
示例15: test_withDayOfYear
import java.time.chrono.HijrahDate; //导入依赖的package包/类
@Test
public void test_withDayOfYear() {
HijrahDate hd = HijrahChronology.INSTANCE.dateYearDay(1434, 1);
for (int i = 1; i <= hd.lengthOfYear(); i++) {
HijrahDate hd2 = hd.with(DAY_OF_YEAR, i);
int doy = hd2.get(DAY_OF_YEAR);
assertEquals(doy, i, "with(DAY_OF_YEAR) incorrect for " + i + " " + hd2);
}
}