日期格式转换计算天数

//获取天数(年)
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);

posted on 2018-10-08 14:30  卜沙卡拉卡  阅读(1341)  评论(0编辑  收藏  举报