Java经典实例:纪元秒和本地日期时间互换
2016-11-28 17:47
239 查看
Java版本:1.8开始
运行输出:
import java.time.Instant; import java.time.ZoneId; import java.time.ZonedDateTime; /** * Created by Frank */ public class CurrentDatetime { public static void main(String[] args) { // 纪元秒和本地日期时间互换 Instant epochSec = Instant.ofEpochSecond(1000000000L); ZoneId zId = ZoneId.systemDefault(); ZonedDateTime then = ZonedDateTime.ofInstant(epochSec, zId); System.out.println("The epoch was a billion seconds old on " + then); } }
运行输出:
The epoch was a billion seconds old on 2001-09-09T09:46:40+08:00[Asia/Shanghai]
相关文章推荐
- Java实现纪元秒和本地日期时间互换的方法【经典实例】
- Java经典实例:把字符串解析为日期时间
- Java经典实例:使用DateFormatter来格式化日期时间
- Python实例讲解 -- 获取本地时间日期(日期计算)
- Java 8 新的时间日期库的20个使用实例
- Python实例讲解 -- 获取本地时间日期(日期计算)
- java基于正则表达式实现时间日期的常用判断操作实例
- Java编程时间日期API实例解析
- JAVA菜鸟入门篇 - 时间处理相关类实例:打印该月日期表 (29)
- Java 以指定日期时间格式获取当前时间、以及每隔一秒刷新一次的方法------附带实例
- JAVA时间日期处理类实例
- Java8新时间与日期API—本地时间与时间戳
- Java 时间日期详细介绍及实例
- LocalDate LocalTime LocalDateTime DateTimeFormatter Java 8 新出的时间(time)和日期(date)的API的使用详细实例
- java8 时间与日期api的总结与实例
- Python实例讲解 -- 获取本地时间日期(日期计算)
- Python实例讲解 -- 获取本地时间日期(日期计算)
- JAVA格式化时间日期的简单实例
- Python实例讲解 -- 获取本地时间日期(日期计算)
- Python实例讲解 -- 获取本地时间日期(日期计算)