Skip to content

Commit

Permalink
Format
Browse files Browse the repository at this point in the history
Signed-off-by: Andy Kwok <[email protected]>
  • Loading branch information
andy-k-improving committed Nov 22, 2024
1 parent 322d16f commit b85826c
Showing 1 changed file with 12 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -152,25 +152,26 @@ private Date parseDateString(List<String> formats, String columnOriginalDate) {
switch (columnFormat) {
case "date_optional_time":
case "strict_date_optional_time":
// It's possible to have date stored in second / millisecond form without explicit format hint.
// It's possible to have date stored in second / millisecond form without explicit
// format hint.
// Parse it on a best-effort basis.
if (StringUtils.isNumeric(columnOriginalDate) ) {
if (StringUtils.isNumeric(columnOriginalDate)) {
long timestamp = Long.parseLong(columnOriginalDate);
if (timestamp > Integer.MAX_VALUE) {
parsedDate = new Date(timestamp);
} else {
parsedDate = new Date(timestamp*1000);
parsedDate = new Date(timestamp * 1000);
}
} else {
parsedDate =
DateUtils.parseDate(
columnOriginalDate,
FORMAT_DOT_OPENSEARCH_DASHBOARDS_SAMPLE_DATA_LOGS_EXCEPTION,
FORMAT_DOT_OPENSEARCH_DASHBOARDS_SAMPLE_DATA_FLIGHTS_EXCEPTION,
FORMAT_DOT_OPENSEARCH_DASHBOARDS_SAMPLE_DATA_FLIGHTS_EXCEPTION_NO_TIME,
FORMAT_DOT_OPENSEARCH_DASHBOARDS_SAMPLE_DATA_ECOMMERCE_EXCEPTION,
FORMAT_DOT_DATE_AND_TIME,
FORMAT_DOT_DATE);
DateUtils.parseDate(
columnOriginalDate,
FORMAT_DOT_OPENSEARCH_DASHBOARDS_SAMPLE_DATA_LOGS_EXCEPTION,
FORMAT_DOT_OPENSEARCH_DASHBOARDS_SAMPLE_DATA_FLIGHTS_EXCEPTION,
FORMAT_DOT_OPENSEARCH_DASHBOARDS_SAMPLE_DATA_FLIGHTS_EXCEPTION_NO_TIME,
FORMAT_DOT_OPENSEARCH_DASHBOARDS_SAMPLE_DATA_ECOMMERCE_EXCEPTION,
FORMAT_DOT_DATE_AND_TIME,
FORMAT_DOT_DATE);
}
break;
case "epoch_millis":
Expand Down

0 comments on commit b85826c

Please sign in to comment.