-
Notifications
You must be signed in to change notification settings - Fork 102
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: type cast error #1468
fix: type cast error #1468
Conversation
@@ -495,8 +495,12 @@ private static Object convert(Object value, String newDataType) { | |||
value = convertNumber(value, s -> new BigDecimal(s).longValue()); | |||
break; | |||
case "DATE": | |||
DateTime dateTime = AnyTimeToDateTime.toDateTime(value); | |||
value = dateTime.toDate(); | |||
if (value instanceof String) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
需要补充单元测试
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
好的
} catch (Exception e) { | ||
throw new RuntimeException(e); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
空字符串会有什么表现?
* Example input: {"value": "DateTime nano 0 seconds 1327149189 timeZone null", "newDateType": "Date"} | ||
* Expected output: IllegalArgumentException(DateTime constructor illegal dateStr: value) | ||
*/ | ||
@Test(expected = RuntimeException.class) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
期望与注释不一致
} else { | ||
DateTime dateTime = AnyTimeToDateTime.toDateTime(value); | ||
value = dateTime.toDate(); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
提供更好的异常信息,例如:日期类型转换失败,字段名:xxx,原始类型: String,原始值:xxx
No description provided.