Skip to content

Commit 2008a81

Browse files
committed
chore[util]: surround exception for stringToDate in TimeUtils
1 parent fb777bf commit 2008a81

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

scheduler/src/main/java/com/zfoo/scheduler/util/TimeUtils.java

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -94,10 +94,13 @@ public static long now() {
9494
*
9595
* @param dateString 日期字符串,如:2018-02-12 10:12:50
9696
* @return <code>Date</code>
97-
* @throws ParseException 解析异常
9897
*/
99-
public static Date stringToDate(String dateString) throws ParseException {
100-
return DATE_FORMAT.get().parse(dateString);
98+
public static Date stringToDate(String dateString) {
99+
try {
100+
return DATE_FORMAT.get().parse(dateString);
101+
} catch (ParseException e) {
102+
throw new RuntimeException(e);
103+
}
101104
}
102105

103106
/**
@@ -118,8 +121,12 @@ public static String simpleDateString() {
118121
return SIMPLE_DATE_FORMAT.get().format(new Date(now()));
119122
}
120123

121-
public static Date dayStringToDate(String dateString) throws ParseException {
122-
return DATE_FORMAT_FOR_DAY.get().parse(dateString);
124+
public static Date dayStringToDate(String dateString) {
125+
try {
126+
return DATE_FORMAT_FOR_DAY.get().parse(dateString);
127+
} catch (ParseException e) {
128+
throw new RuntimeException(e);
129+
}
123130
}
124131
// --------------------------------------日期判断--------------------------------------
125132

0 commit comments

Comments
 (0)