当前位置:网站首页>计算两个时间相差的天数(支持跨月、跨年)
计算两个时间相差的天数(支持跨月、跨年)
2022-06-13 05:26: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);
}
边栏推荐
- C language learning log 12.5
- Binary search and binary answer
- Clause 48: understand template metaprogramming
- 关于匿名内部类
- Django uploads local binaries to the database filefield field
- Modification and analysis of libcoap source code by Hongmeng device discovery module
- Shell instance
- Dynamic and static libraries
- How to Algorithm Evaluation Methods
- Chapter 2 process management
猜你喜欢

Metartc4.0 integrated ffmpeg compilation

Binary search and binary answer

metaRTC4.0稳定版发布

Case - the list set stores student objects and traverses them in three ways

Case - grade sorting - TreeSet set storage

Small project - household income and expenditure software (1)
![[China & some provinces and cities] JSON file for offline map visualization](/img/ea/0c552e1e133f693b9902c54c2e09c8.jpg)
[China & some provinces and cities] JSON file for offline map visualization

MySQL main query and sub query

External sort

Dynamic and static libraries
随机推荐
Automatic database backup (using Navicat)
C language learning log 12.5
行情绘图课程大纲1-基础知识
Case - the list set stores student objects and traverses them in three ways
System file interface open
Enhanced for loop
C language learning log 10.5
[China & some provinces and cities] JSON file for offline map visualization
Float type value range
Sub paragraph of Chapter 16
COAP protocol libcoap API
Case - the ArrayList collection stores student objects and traverses them in three ways
File descriptorfile description
About anonymous inner classes
[multi thread programming] the future interface obtains thread execution result data
metaRTC4.0稳定版发布
Dynamic and static libraries
使用EasyDarwin+FFmpeg实现rtsp推流
Violence enumeration~
Article 49: understanding the behavior of new handler