当前位置:网站首页>Calculate the number of days difference between localdates, which is convenient and fast
Calculate the number of days difference between localdates, which is convenient and fast
2022-07-16 06:06:00 【Kuo-Teng】
Calculation LocalDate The difference between days
1. Calculation LocalDate The method of the difference between days
public static Long claculateGapBetweenTwoLocalDate(LocalDate localDateStart, LocalDate localDateEnd) {
Duration duration = Duration.between(localDateStart.atStartOfDay(), localDateEnd.atStartOfDay());
return duration.toDays();
}
2. Example of calculation process and results
- You can use the method to convert the string to
LocalDate:public static LocalDate transferString2LocalDate(String s) { DateTimeFormatter fmt = DateTimeFormatter.ofPattern("yyyy-MM-dd"); return LocalDate.parse(s, fmt); } - With
2022-06-01to2022-06-03For example :public static void main(String[] args) { LocalDate start = transferString2LocalDate("2022-06-01"); LocalDate end = transferString2LocalDate("2022-06-03"); System.out.println(claculateGapBetweenTwoLocalDate(start, end)); } - Running results
2
边栏推荐
- chrome浏览器91版本SameSite by default cookies被移除后的解决方案,Chrome中跨域POST请求无法携带Cookie的解决方案
- Notes on network communication security -- static routing and experiment
- 欧拉Talk | 开发者社区体验坦白局7月14日19:30约起
- 编译原理-词法分析器设计
- How to solve the "Impossible Triangle" problem of data flow?
- PHP对接微信支付--Native tp5框架
- Garbage collection mechanism
- Class loader + reflection +properties
- 39.js-- scope
- [BJDCTF2020]Cookie is so stable
猜你喜欢

Nftscan Developer Platform launches Multi Chain NFT data pro API service

Compilation principle - parser design

Summer precipitation Web Learning -- PHP Foundation

How is the advertising model with 100 billion parameters refined?

关于 Visual Studio 2022的安装与使用

Notes on network communication security -- OSPF theory and experiment

Network security emergency response terminal detection and response technology

unity实验-重力撞墙

Moss privacy computing all-in-one machine has passed 83 evaluations of Shenzhen Guojin evaluation center

Buuctf mysterious Tornado
随机推荐
MSF infiltrates Win2003 with eternal blue
Ant group open source large-scale video infringement positioning data set
Vue+axios+mysql realizes paging query, condition query and batch deletion
Convert list data to tree data
Class loader + reflection +properties
sniffer Pro對ARP協議的分析、捕獲與模擬攻擊
Get the set of parent node IDs from top to bottom
将BufferedImage转为byte[]数组,亲测可用
unity实验-重力撞墙
Graphic and image programming practice course report
内网渗透笔记——:)一个笑脸
Buuctf, let's sing a song
40.js -- the same name identifier promotion problem
MSF利用永恒之蓝渗透win2003
Find a value of tree data
PHP docking wechat payment native TP5 framework
Oracle learning
Experimental report on using spark to predict repeat customers
Notes on network communication security -- static routing and experiment
Nftscan Developer Platform launches Multi Chain NFT data pro API service