|
@@ -55,6 +55,11 @@ public class FormulaUtil {
|
|
|
* @return
|
|
|
*/
|
|
|
public static LocalDateTime parseStringToLocalDateTime(String strDate, String pattern) {
|
|
|
+
|
|
|
+ if (!strDate.matches(".*\\d.*")) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
if (StringUtils.isNotEmpty(strDate)) {
|
|
|
strDate = strDate.replace(".", "");
|
|
|
strDate = strDate.replace("-","");
|
|
@@ -62,8 +67,15 @@ public class FormulaUtil {
|
|
|
strDate = strDate.replace("月","");
|
|
|
strDate = strDate.replace("日","");
|
|
|
}
|
|
|
+
|
|
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern(pattern);
|
|
|
- LocalDate date = LocalDate.parse(strDate, formatter);
|
|
|
+ LocalDate date = null;
|
|
|
+ try {
|
|
|
+ date = LocalDate.parse(strDate, formatter);
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ return null;
|
|
|
+ }
|
|
|
return LocalDateTime.of(date, LocalTime.MIN);
|
|
|
}
|
|
|
|