`

java 比较日期大小

阅读更多
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
Date vaiDate = _user.getValidateTime();
String dateStr = dateFormat.format(vaiDate);

//如果密码日期为空,则默认为过期,需要重新修改密码
if (null == dateStr || "".equals(dateStr)){
dateStr = "2012-01-01";
}

//系统当前时间
Date date = new Date();
int year = date.getYear() - vaiDate.getYear();
int month = date.getMonth() - vaiDate.getMonth();
if (year > 0){
month = (year * 12) + month;
}

/** 判断月份小于3的时候,密码过期  判断对密码的长度进行校验**/
if (month > 3 || (password.length() < 6) || (password.length() > 20)){
getSession().setAttribute("paswdveri", "YES");
}else {
getSession().setAttribute("paswdveri", "NO");
}
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics