java.time.chrono.JapaneseDate类的toEpochDay()方法用于获取当前日语日期与1970-01-01之间的纪元天数。
用法:
public long toEpochDay()
参数:此方法不接受任何参数作为参数。
返回值:此方法返回当前回历日期和1389-10-22之间的纪元天数。
下面的示例说明了toEpochDay()方法:
范例1:
Java
// Java program to demonstrate
// toEpochDay() method
import java.util.*;
import java.io.*;
import java.time.*;
import java.time.chrono.*;
import java.time.temporal.*;
public class GFG {
public static void main(String[] argv)
{
try {
// Creating and initializing
// JapaneseDate Object
JapaneseDate hidate = JapaneseDate.now();
// Getting no of ephoch days present
// by using toEpochDay() method
long length = hidate.toEpochDay();
// Display the result
System.out.println("EpochDay:"
+ length);
}
catch (DateTimeException e) {
System.out.println("passed parameter can"
+ " not form a date");
System.out.println("Exception thrown:"
+ e);
}
}
}
输出:
EpochDay:18365
范例2:
Java
// Java program to demonstrate
// toEpochDay() method
import java.util.*;
import java.io.*;
import java.time.*;
import java.time.chrono.*;
import java.time.temporal.*;
public class GFG {
public static void main(String[] argv)
{
try {
// Creating and initializing
// JapaneseDate Object
JapaneseDate hidate
= JapaneseDate.of(1970, 01, 01);
// Getting no of ephoch days present
// by using toEpochDay() method
long length = hidate.toEpochDay();
// Display the result
System.out.println("EpochDay:"
+ length);
}
catch (DateTimeException e) {
System.out.println("passed parameter can"
+ " not form a date");
System.out.println("Exception thrown:"
+ e);
}
}
}
输出:
EpochDay:0
参考: https://docs.oracle.com/javase/9/docs/api/java/time/chrono/JapaneseDate.html#toEpochDay-
相关用法
- Java HijrahDate toEpochDay()用法及代码示例
- Java ChronoLocalDate toEpochDay()用法及代码示例
- Java JapaneseDate from()用法及代码示例
- Java JapaneseDate of(int, int, int)用法及代码示例
- Java JapaneseDate getLong()用法及代码示例
- Java JapaneseDate getChronology()用法及代码示例
- Java JapaneseDate equals()用法及代码示例
- Java JapaneseDate atTime()用法及代码示例
- Java JapaneseDate getEra()用法及代码示例
- Java JapaneseDate of(JapaneseEra,int, int, int)用法及代码示例
- Java JapaneseDate isSupported()用法及代码示例
- Java JapaneseDate hashCode()用法及代码示例
- Java JapaneseDate range()用法及代码示例
- Java JapaneseDate toString()用法及代码示例
- Java JapaneseDate now(ZoneId)用法及代码示例
注:本文由纯净天空筛选整理自RohitPrasad3大神的英文原创作品 JapaneseDate toEpochDay() method in Java with Example。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。