关于日期格式化的笔记

1,获取某一日期N天数后的日期

SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Calendar calendar = Calendar.getInstance();
calendar.setTime(oldDate);
calendar.add(Calendar.DATE, days);
Date newDate = calendar.getTime();
return format.parse(format.format(newDate));

2, 日期比较,如果A大于 B返回true,反之返回false

public static boolean compareDate(Date A,Date B){
  return A.after(B)?true:false;
}

 

posted on 2016-07-23 12:29  java疯子  阅读(101)  评论(0编辑  收藏  举报

导航