当前位置:网站首页>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
边栏推荐
- A heavy sword without a blade is a great skill
- Recommended scheme of national manufactured electronic components for intelligent electronic scales
- Error occurs when thymeleaf th: value is null
- Recommended scheme for national production of electronic components for wireless charging
- 简单的拖拽物体到物品栏
- leetcode003--判断一个整数是否为回文数
- Detailed explanation of life cycle component of jetpack
- Luogu p1858 [multi person knapsack] (knapsack seeking the top k optimal solution)
- Improving 3D object detection with channel wise transformer
- 229. Find mode II
猜你喜欢
Recommended scheme of national manufactured electronic components
程序员抱怨:1万2的工资我真的活不下去了,网友:我3千咋说
Recommended scheme for national production of electronic components for wireless charging
Kotlin. The binary version of its metadata is 1.6.0, expected version is 1.1.15.
Unity rawimage background seamlessly connected mobile
Coinbase: basic knowledge, facts and statistics about cross chain bridge
Programmers complain: I really can't live with a salary of 12000. Netizen: how can I say 3000
协程与多进程的完美结合
Use recyclerview to realize left-right side-by-side classification selection
test
随机推荐
Shanghai Hangxin technology sharing 𞓜 overview of safety characteristics of acm32 MCU
shell wc (统计字符数量)的基本使用
How to regulate intestinal flora? Introduction to common natural substances, probiotics and prebiotics
229. Find mode II
FAQ of foreign lead and alliance Manager
QML advanced (IV) - drawing custom controls
Installation and use of Apache bench (AB pressure test tool)
Redis command Encyclopedia
Recommended scheme of national manufactured electronic components for intelligent electronic scales
Leetcode005 -- delete duplicate elements in the array in place
leetcode001--返回和为target的数组元素的下标
用D435i录制自己的数据集运行ORBslam2并构建稠密点云
Installation du compilateur croisé de la plateforme zynq
The unity camera rotates with the mouse
Use recyclerview to realize left-right side-by-side classification selection
Unity camera rotation with sliding effect (rotation)
La caméra Unity tourne avec la souris
Create VPC in AWS console (no plate)
leetcode004--罗马数字转整数
Mysql50 basic exercises