/**获取一年的日期
* @throws ParseException
*/
public void getYearDate() throws ParseException {
String dateStart="2018-01-01";
String dateEnd="2018-12-31";
SimpleDateFormat date=new SimpleDateFormat("yyyy-MM-dd");
long startTime = date.parse(dateStart).getTime();//start
long endTime = date.parse(dateEnd).getTime();//end
long day=1000*60*60*24;
for(long i=startTime;i<=endTime;i+=day) {
System.out.println(date.format(new Date(i)));
}
}
java 获取一年的日期
最新推荐文章于 2024-07-15 03:06:54 发布