healchow commented on code in PR #5809: URL: https://github.com/apache/inlong/pull/5809#discussion_r966590035
########## inlong-sdk/sort-sdk/src/main/java/org/apache/inlong/sdk/sort/util/StringUtil.java: ########## @@ -106,4 +245,26 @@ public static String formatDate(Date date) { return sdf.format(date); } + public static long parseDateTime(String value) { + try { + if (value.length() < 8) { + return -1; + } else if (value.length() <= 9) { + SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyyMMdd"); + Date date = simpleDateFormat.parse(value.substring(0, 8)); + return new Timestamp(date.getTime()).getTime(); + } else if (value.length() <= 11) { + SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyyMMddHH"); + Date date = simpleDateFormat.parse(value.substring(0, 10)); + return new Timestamp(date.getTime()).getTime(); + } else { + SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyyMMddHHmm"); + Date date = simpleDateFormat.parse(value.substring(0, 12)); + return new Timestamp(date.getTime()).getTime(); + } + } catch (ParseException e) { + throw new IllegalArgumentException("Unexpected time format : " + value + "."); Review Comment: Not need to append `.` at the end of the exception message. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@inlong.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org