当前位置:网站首页>Calculate the number of days between two times (supports cross month and cross year)
Calculate the number of days between two times (supports cross month and cross year)
2022-06-13 05:30:00 【Nagging program dog】
Calculate the number of days between two times ( Support cross month 、 straddle old and new years ):
/** * JDK 8 Calculate the number of days between two times , Support cross month 、 straddle old and new years * @param startTimeStamp Start timestamp * @param endTimeStamp End timestamp * @return Days apart , If the start time is greater than the end time , * Returns the corresponding complex number */
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);
}
边栏推荐
- Luogu p1088 Martians
- Time display of the 12th Blue Bridge Cup
- Introduction to R language 4--- R language process control
- Course outline of market drawing 1- basic knowledge
- 【多线程】线程池核心类-ThreadPoolExecutor
- 使用EasyDarwin+FFmpeg实现rtsp推流
- Create a harbor image library from the command line
- Solution to prompt "permission is required to perform this operation" (file cannot be deleted) when win10 deletes a file
- 17.6 unique_ Lock details
- Jeffery0207 blog navigation
猜你喜欢
关于匿名内部类
C language learning log 12.5
JS output uincode code
MySQL built-in functions
metaRTC4.0稳定版发布
Case -- the HashSet set stores the student object and traverses
Metaltc4.0 stable release
Pychart error resolution: process finished with exit code -1073741819 (0xc0000005)
Simple SR: best buddy Gans for highly detailed image super resolution
lookup
随机推荐
std::condition_ variable::wait_ for
[multi thread programming] the future interface obtains thread execution result data
C language learning log 10.5
Pyqt5 controls qpixmap, qlineedit qsplitter, qcombobox
Understanding inode
2020 personal annual summary
Create a harbor image library from the command line
17.6 unique_lock详解
MySQL built-in functions
Case - grade sorting - TreeSet set storage
【多线程编程】Future接口获取线程执行结果数据
Pyqt5 module
Clause 47: please use traits classes to represent type information
Django uploads local binaries to the database filefield field
[multithreading] thread pool core class -threadpoolexecutor
About anonymous inner classes
System performance monitoring system
Chapter 2 process management
Dynamic programming - longest common substring
MySQL installation, architecture and management