|
@@ -241,7 +241,7 @@ public class DateUtils extends PropertyEditorSupport {
|
|
Date dt = new Date();
|
|
Date dt = new Date();
|
|
DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
String nowTime = df.format(dt);
|
|
String nowTime = df.format(dt);
|
|
- java.sql.Timestamp buydate = java.sql.Timestamp.valueOf(nowTime);
|
|
|
|
|
|
+ Timestamp buydate = Timestamp.valueOf(nowTime);
|
|
return buydate;
|
|
return buydate;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -1287,28 +1287,8 @@ public class DateUtils extends PropertyEditorSupport {
|
|
return null;
|
|
return null;
|
|
}
|
|
}
|
|
|
|
|
|
- public static int dateDiff(String start, String end){
|
|
|
|
- //设置转换的日期格式
|
|
|
|
- SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
|
- //开始时间
|
|
|
|
- Date startDate = null;
|
|
|
|
- Date endDate = null;
|
|
|
|
- try {
|
|
|
|
- startDate = sdf.parse(start);
|
|
|
|
- endDate = sdf.parse(end);
|
|
|
|
- } catch (ParseException e) {
|
|
|
|
- e.printStackTrace();
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- //得到相差的天数 betweenDate
|
|
|
|
- long betweenDate = (endDate.getTime() - startDate.getTime())/(60*60*24*1000);
|
|
|
|
- return (int)betweenDate;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- public static Date addMonth(Date date){
|
|
|
|
- Calendar calendar = Calendar.getInstance();//日历对象
|
|
|
|
- calendar.add(Calendar.MONTH, -1);//月份减一
|
|
|
|
- return calendar.getTime();
|
|
|
|
|
|
+ public static void main(String[] args) throws ParseException {
|
|
|
|
+ System.out.println(calDiffMonth(DateUtils.parseDate("2019-04-01","yyyy-MM-dd"),new Date()));
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|