日期格式转换计算天数

//获取天数(年)
Long start1 = null;
Long end1= null;
SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd");
try {
Date startdate = sdf1.parse(end);
start1 = startdate.getTime();
Date enddate = sdf1.parse(end.substring(0, 4)+"-01-01");
end1 = enddate.getTime();
} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
int dayy = (int) ((start1-end1)/(24*60*60*1000)+1);

猜你喜欢

转载自www.cnblogs.com/cwkzhy/p/9754145.html