1313import java .time .LocalDateTime ;
1414import java .time .LocalTime ;
1515import java .time .ZoneOffset ;
16+ import java .time .ZonedDateTime ;
17+ import java .time .format .DateTimeFormatter ;
1618import java .time .format .DateTimeParseException ;
1719import java .time .temporal .ChronoUnit ;
1820import java .util .Objects ;
@@ -31,17 +33,24 @@ public class ExprTimestampValue extends AbstractExprValue {
3133 /**
3234 * Constructor with timestamp string.
3335 *
34- * @param timestamp a date or timestamp string (does not accept time string)
36+ * @param timestamp a date or timestamp string (does not accept time string). It accepts both ISO
37+ * 8601 format and {@code yyyy-MM-dd HH:mm:ss[.SSSSSSSSS]} format
3538 */
3639 public ExprTimestampValue (String timestamp ) {
3740 try {
38- this .timestamp =
39- LocalDateTime .parse (timestamp , DateTimeFormatters .DATE_TIMESTAMP_FORMATTER )
40- .toInstant (ZoneOffset .UTC );
41+ LocalDateTime ldt ;
42+ try {
43+ ldt = LocalDateTime .parse (timestamp , DateTimeFormatters .DATE_TIMESTAMP_FORMATTER );
44+ } catch (DateTimeParseException ignored ) {
45+ ZonedDateTime zdt = ZonedDateTime .parse (timestamp , DateTimeFormatter .ISO_DATE_TIME );
46+ ldt = zdt .withZoneSameInstant (ZoneOffset .UTC ).toLocalDateTime ();
47+ }
48+ this .timestamp = ldt .toInstant (ZoneOffset .UTC );
4149 } catch (DateTimeParseException e ) {
4250 throw new ExpressionEvaluationException (
4351 String .format (
44- "timestamp:%s in unsupported format, please use 'yyyy-MM-dd HH:mm:ss[.SSSSSSSSS]'" ,
52+ "timestamp:%s in unsupported format, please use 'yyyy-MM-dd HH:mm:ss[.SSSSSSSSS]' or"
53+ + " ISO 8601 format" ,
4554 timestamp ));
4655 }
4756 }
0 commit comments