增加日期过期验证方法
This commit is contained in:
parent
1ea415c578
commit
f4afb708a7
@ -2,6 +2,7 @@ package ink.wgink.util.date;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.joda.time.DateTime;
|
||||
import org.joda.time.format.DateTimeFormat;
|
||||
|
||||
import java.text.DateFormat;
|
||||
import java.text.ParseException;
|
||||
@ -454,4 +455,22 @@ public class DateUtil {
|
||||
}
|
||||
return PM;
|
||||
}
|
||||
|
||||
/**
|
||||
* 时间是否过期
|
||||
*
|
||||
* @param date
|
||||
* @return
|
||||
*/
|
||||
public static boolean isDateExpired(String date) {
|
||||
if (StringUtils.isBlank(date)) {
|
||||
return false;
|
||||
}
|
||||
DateTime now = DateTime.now();
|
||||
DateTime expiredDateTime = DateTime.parse(date, DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss"));
|
||||
if (expiredDateTime.isAfter(now)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user