本文整理汇总了Java中java.time.chrono.ChronoLocalDate.getLong方法的典型用法代码示例。如果您正苦于以下问题:Java ChronoLocalDate.getLong方法的具体用法?Java ChronoLocalDate.getLong怎么用?Java ChronoLocalDate.getLong使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.time.chrono.ChronoLocalDate
的用法示例。
在下文中一共展示了ChronoLocalDate.getLong方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: test_epoch
import java.time.chrono.ChronoLocalDate; //导入方法依赖的package包/类
/**
* Compute the number of days from the Epoch and compute the date from the number of days.
*/
@Test(dataProvider = "calendarNameAndType")
public void test_epoch(String name, String alias) {
Chronology chrono = Chronology.of(name); // a chronology. In practice this is rarely hardcoded
ChronoLocalDate date1 = chrono.dateNow();
long epoch1 = date1.getLong(ChronoField.EPOCH_DAY);
ChronoLocalDate date2 = date1.with(ChronoField.EPOCH_DAY, epoch1);
assertEquals(date1, date2, "Date from epoch day is not same date: " + date1 + " != " + date2);
long epoch2 = date1.getLong(ChronoField.EPOCH_DAY);
assertEquals(epoch1, epoch2, "Epoch day not the same: " + epoch1 + " != " + epoch2);
}
示例2: test_dateEpochDay
import java.time.chrono.ChronoLocalDate; //导入方法依赖的package包/类
@Test(dataProvider = "calendarNameAndType")
public void test_dateEpochDay(String name, String alias) {
Chronology chrono = Chronology.of(name);
ChronoLocalDate date = chrono.dateNow();
long epochDay = date.getLong(ChronoField.EPOCH_DAY);
ChronoLocalDate test = chrono.dateEpochDay(epochDay);
assertEquals(test, date);
}