java 时间相关操作
程序员文章站
2022-05-27 11:57:53
...
java 时间相关操作
(1)
public static boolean hasLicense(APP_INFO orgAppInfo) {
// String endDate = orgAppInfo.endDate;
String startDateStr = orgAppInfo.startDate;
Date startDate = null;
if (startDateStr.contains("-")) {//兼容startDateStr 是毫秒的情况
try {
startDate = DateTimeUtil.getDate4Str(startDateStr);
} catch (ParseException e) {
e.printStackTrace();
}
} else {
startDate = new Date(Long.parseLong(startDateStr));//如果是毫秒
}
if (null == startDate) {
return false;
}
return new Date().before(startDate);
}
(2)
if (!StringUtil.isNullOrEmpty(startDate) && startDate.length() < 11) {
startDate += " 00:00:00";
}
if (!StringUtil.isNullOrEmpty(endDate) && endDate.length() < 11) {
endDate += " 23:59:59";
}
if (!StringUtil.isNullOrEmpty(startDate) && startDate.length() < 11) {
startDate += " 00:00:00";
}
if (!StringUtil.isNullOrEmpty(endDate) && endDate.length() < 11) {
endDate += " 23:59:59";
}
(3)待续