forked from elastic/elasticsearch
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SQL: Move internals from Joda to java.time (elastic#35649)
Remove/Limit usage of Joda through-out the processors and functions Use ZonedDateTime wherever possible instead of long/tzId Fix elastic#35633
- Loading branch information
Showing
39 changed files
with
451 additions
and
346 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
x-pack/plugin/sql/sql-proto/src/main/java/org/elasticsearch/xpack/sql/proto/DateUtils.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
package org.elasticsearch.xpack.sql.proto; | ||
|
||
import java.time.ZonedDateTime; | ||
import java.time.format.DateTimeFormatter; | ||
import java.time.format.DateTimeFormatterBuilder; | ||
import java.util.Locale; | ||
|
||
import static java.time.format.DateTimeFormatter.ISO_LOCAL_DATE; | ||
import static java.time.temporal.ChronoField.HOUR_OF_DAY; | ||
import static java.time.temporal.ChronoField.MILLI_OF_SECOND; | ||
import static java.time.temporal.ChronoField.MINUTE_OF_HOUR; | ||
import static java.time.temporal.ChronoField.SECOND_OF_MINUTE; | ||
|
||
public class DateUtils { | ||
|
||
private static final DateTimeFormatter ISO_WITH_MILLIS = new DateTimeFormatterBuilder() | ||
.parseCaseInsensitive() | ||
.append(ISO_LOCAL_DATE) | ||
.appendLiteral('T') | ||
.appendValue(HOUR_OF_DAY, 2) | ||
.appendLiteral(':') | ||
.appendValue(MINUTE_OF_HOUR, 2) | ||
.appendLiteral(':') | ||
.appendValue(SECOND_OF_MINUTE, 2) | ||
.appendFraction(MILLI_OF_SECOND, 3, 3, true) | ||
.appendOffsetId() | ||
.toFormatter(Locale.ROOT); | ||
|
||
private DateUtils() {} | ||
|
||
|
||
public static String toString(ZonedDateTime dateTime) { | ||
return dateTime.format(ISO_WITH_MILLIS); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.