当前位置:网站首页>Gets all dates between two times
Gets all dates between two times
2022-04-23 04:43:00 【Mount MONI】
Two hours :start="2019 year 11 month 13 Japan " end="2019 year 12 month 05 Japan "
/***
* <p>Title: getBetweenDates2</p>
* <p>Description: Gets all dates between two times </p>
* @param start
* @param end
* @return
*/
public static List<String> getBetweenDates2(String start, String end) {
List<String> result = new ArrayList<String>();
try {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy year MM month dd Japan ");
Date start_date = sdf.parse(start);
Date end_date = sdf.parse(end);
Calendar tempStart = Calendar.getInstance();
tempStart.setTime(start_date);
Calendar tempEnd = Calendar.getInstance();
tempEnd.setTime(end_date);
while (tempStart.before(tempEnd) || tempStart.equals(tempEnd)) {
result.add(sdf.format(tempStart.getTime()));
tempStart.add(Calendar.DAY_OF_YEAR, 1);
}
} catch (ParseException e) {
e.printStackTrace();
}
//Collections.reverse(result);
return result;
}
The test method
public static void main(String[] args) throws IOException, ParseException {
List<String> betweenDates = getBetweenDates2("2019 year 11 month 13 Japan ","2019 year 12 month 05 Japan ");
System.out.println(JSONObject.toJSONString(betweenDates));
}
版权声明
本文为[Mount MONI]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204220558291840.html
边栏推荐
- 三十六计是什么
- Improving 3D object detection with channel wise transformer
- Record your own dataset with d435i, run orbslam2 and build a dense point cloud
- 229. 求众数 II
- AWS eks add cluster user or Iam role
- 华为机试--高精度整数加法
- 229. Find mode II
- Recursive call -- Enumeration of permutations
- QML advanced (V) - realize all kinds of cool special effects through particle simulation system
- Small volume Schottky diode compatible with nsr20f30nxt5g
猜你喜欢
520. Detect capital letters
win10, mysql-8.0.26-winx64. Zip installation
Luogu p1858 [multi person knapsack] (knapsack seeking the top k optimal solution)
383. 赎金信
第四章 --- 了解标准设备文件、过滤器和管道
Recommended scheme for national production of electronic components of wireless keyboard
Mysql50 basic exercises
Youqilin 22.04 lts version officially released | ukui 3.1 opens a new experience
test
Druid -- JDBC tool class case
随机推荐
No such file or directory problem while executing shell
PIP3 installation requests Library - the most complete pit sorting
Solutions to the failure of sqoop connection to MySQL
IDE Idea 自动编译 与 On Upate Action 、 On Frame Deactivation 的配置
Supplément: annotation
阿里十年技术专家联合打造“最新”Jetpack Compose项目实战演练(附Demo)
Migrate from MySQL database to AWS dynamodb
La caméra Unity tourne avec la souris
Installation and deployment of Flink and wordcount test
C language: Advanced pointer
Shanghai Hangxin technology sharing 𞓜 overview of safety characteristics of acm32 MCU
leetcode004--罗马数字转整数
Leetcode005 -- delete duplicate elements in the array in place
Phishing for NFT
C language: spoof games
2021数学建模国赛一等奖经验总结与分享
Leetcode009 -- search the target value in the array with binary search
JS generates a specified number of characters according to some words
Jetpack 之 LifeCycle 组件使用详解
简单的拖拽物体到物品栏