使用Putsql,如果遇到时间类型的参数。提示:
cannot convert start_time to timestamps
putsql源码:
// Backwards compatibility note: Format was unsupported for a timestamp field.
if (valueFormat.equals("")) {
if(LONG_PATTERN.matcher(parameterValue).matches()){
lTimestamp = Long.parseLong(parameterValue);
} else {
final SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
java.util.Date parsedDate = dateFormat.parse(parameterValue);
lTimestamp = parsedDate.getTime();
}
} else {
final DateTimeFormatter dtFormatter = getDateTimeFormatter(valueFormat);
TemporalAccessor accessor = dtFormatter.parse(parameterValue);
java.util.Date parsedDate = java.util.Date.from(Instant.from(accessor));
lTimestamp = parsedDate.getTime();
}
必须要把日期转成yyyy-MM-dd HH:mm:ss.SSS 格式
解决方案
可以使用updateAttribute,time -> ${time:toDate(“yyyy-MM-dd HH:mm:ss”):toNumber():format(“yyyy-MM-dd HH:mm:ss.SSS”)}