博客
关于我
JDK8 三种时间获取方法 日期加减
阅读量:534 次
发布时间:2019-03-09

本文共 774 字,大约阅读时间需要 2 分钟。

//2018-12-04        LocalDate localDate = LocalDate.now();        //16:14:56.892        LocalTime localTime = LocalTime.now();        //2018-12-04T16:14:56.892        LocalDateTime localDateTime = LocalDateTime.now();        //16:14:5(去除纳秒)        LocalTime time = LocalTime.now().withNano(0);                //2018-12-04 16:17:55        String now1 = LocalDateTime.now().withNano(0).toString().replace("T", " ");        String now2 = LocalDate.now()+" "+LocalTime.now().withNano(0);

日期加减

//三天后LocalDate afterThreeDays = LocalDate.now().plusDays(3);//三天前LocalDate threeDaysAgo = LocalDate.now().minusDays(3);LocalDate now = LocalDate.now();LocalDate date = LocalDate.parse("2020-01-30");long day1 = now.toEpochDay();long day2 = date.toEpochDay();//相差多少天long day = day2-day1;

 

转载地址:http://fhxiz.baihongyu.com/

你可能感兴趣的文章
nginx反向代理
查看>>
nginx反向代理、文件批量改名及统计ip访问量等精髓总结
查看>>
Nginx反向代理与正向代理配置
查看>>
Nginx反向代理及负载均衡实现过程部署
查看>>
Nginx反向代理是什么意思?如何配置Nginx反向代理?
查看>>
nginx反向代理解决跨域问题,使本地调试更方便
查看>>
Nginx反向代理配置
查看>>
Nginx启动SSL功能,并进行功能优化,你看这个就足够了
查看>>
nginx启动脚本
查看>>
Nginx在Windows上和Linux上(Docker启动)分别配置基本身份认证示例
查看>>
Nginx在Windows下载安装启动与配置前后端请求代理
查看>>
Nginx多域名,多证书,多服务配置,实用版
查看>>
nginx如何实现图片防盗链
查看>>
Nginx学习总结(13)——Nginx 重要知识点回顾
查看>>
Nginx学习总结(14)——Nginx配置参数详细说明与整理
查看>>
Nginx安装与常见命令
查看>>
Nginx安装及配置详解
查看>>
Nginx实战经验分享:从小白到专家的成长历程!
查看>>
Nginx实现反向代理负载均衡
查看>>
nginx实现负载均衡
查看>>