当前位置:网站首页>计算两个时间相差的天数(支持跨月、跨年)
计算两个时间相差的天数(支持跨月、跨年)
2022-06-13 09:05:00 【关忆北.】
计算两个时间相差的天数(支持跨月、跨年):
/**
* JDK 8计算两个时间相差的天数,支持跨月、跨年
* @param startTimeStamp 开始时间戳
* @param endTimeStamp 结束时间戳
* @return 相距天数,若开始时间大于结束时间,
* 则返回对应复数
*/
public long diffDays(long startTimeStamp,long endTimeStamp){
LocalDate startTime = Instant.ofEpochMilli(startTimeStamp).atZone(ZoneOffset.ofHours(8)).toLocalDate();
LocalDate endTime = Instant.ofEpochMilli(endTimeStamp).atZone(ZoneOffset.ofHours(8)).toLocalDate();
return ChronoUnit.DAYS.between(startTime, endTime);
}
边栏推荐
- 20211006 integral, differential and projection belong to linear transformation
- Tutorial (5.0) 01 Product introduction and installation * fortiedr * Fortinet network security expert NSE 5
- 20211006 积分、微分、投影均属于线性变换
- C language: timer principle
- 20211028 Stabilizability
- IP address introduction
- Collection of various books
- 共享模型之不可变
- Yolov5 model evaluation
- 攻防世界PWN play 条件竞争漏洞的利用
猜你喜欢
Class loading overview
turtle库的使用数字时钟模拟时钟动态显示
Drill down to protobuf - Introduction
Tutorial (5.0) 02 Management * fortiedr * Fortinet network security expert NSE 5
线上调试工具Arthas高级
How many TCP connections can a machine create at most?
C language: deep understanding of character functions and string functions (2)
Message Oriented Middleware
Detailed explanation of C language callback function
Simulink的Variant Model和Variant Subsystem用法
随机推荐
LeetCode 剑指 Offer 30. 包含min函数的栈
LeetCode 72. 编辑距离
C/S模型与P2P模型
Detailed explanation of C language callback function
Subspace of 20211004 matrix
You don't know the usage of stringstream
20211005 Hermite矩阵及几个性质
Neo4j环境搭建
Tutorial (5.0) 03 Security policy * fortiedr * Fortinet network security expert NSE 5
Pytorch same structure different parameter name model loading weight
Neo4j - CQL use
Number of parameters of pytorch statistical model
Simulink如何添加模块到Library Browser
Simulink的Variant Model和Variant Subsystem用法
C language: shortcut keys commonly used in VS
Lecture par lots de tous les fichiers vocaux sous le dossier
A very detailed blog about the implementation of bilinear interpolation by opencv
Necessary and sufficient conditions for diagonalization of 20211115 matrix; The full rank matrix does not necessarily have n linearly independent eigenvectors; Symmetric matrices must be diagonalized
C language: sanziqi
202012 CCF test questions