forked from broadinstitute/cromwell
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Always shift times to UTC, and render w/ 3 digits of millis
- Loading branch information
Showing
13 changed files
with
137 additions
and
41 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
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,22 @@ | ||
package common.util | ||
|
||
import java.time.format.DateTimeFormatter | ||
import java.time.{OffsetDateTime, ZoneOffset} | ||
|
||
object TimeUtil { | ||
/** | ||
* Instead of "one of" the valid ISO-8601 formats, standardize on this one: | ||
* https://github.com/openjdk/jdk/blob/jdk8-b120/jdk/src/share/classes/java/time/OffsetDateTime.java#L1886 | ||
*/ | ||
private val Iso8601MillisecondsFormat = DateTimeFormatter.ofPattern("uuuu-MM-dd'T'HH:mm:ss.SSSXXXXX") | ||
|
||
implicit class EnhancedOffsetDateTime(val offsetDateTime: OffsetDateTime) extends AnyVal { | ||
/** | ||
* Discards the original timezone and shifts the time to UTC, then returns the ISO-8601 formatted string with | ||
* exactly three digits of milliseconds. | ||
*/ | ||
def toUtcMilliString: String = Option(offsetDateTime).map( | ||
_.atZoneSameInstant(ZoneOffset.UTC).format(Iso8601MillisecondsFormat) | ||
).orNull | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
cromwellApiClient/src/main/scala/cromwell/api/model/TimeUtil.scala
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,22 @@ | ||
package cromwell.api.model | ||
|
||
import java.time.format.DateTimeFormatter | ||
import java.time.{OffsetDateTime, ZoneOffset} | ||
|
||
object TimeUtil { | ||
/** | ||
* Instead of "one of" the valid ISO-8601 formats, standardize on this one: | ||
* https://github.com/openjdk/jdk/blob/jdk8-b120/jdk/src/share/classes/java/time/OffsetDateTime.java#L1886 | ||
*/ | ||
private val Iso8601MillisecondsFormat = DateTimeFormatter.ofPattern("uuuu-MM-dd'T'HH:mm:ss.SSSXXXXX") | ||
|
||
implicit class EnhancedOffsetDateTime(val offsetDateTime: OffsetDateTime) extends AnyVal { | ||
/** | ||
* Discards the original timezone and shifts the time to UTC, then returns the ISO-8601 formatted string with | ||
* exactly three digits of milliseconds. | ||
*/ | ||
def toUtcMilliString: String = Option(offsetDateTime).map( | ||
_.atZoneSameInstant(ZoneOffset.UTC).format(Iso8601MillisecondsFormat) | ||
).orNull | ||
} | ||
} |
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
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
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