Skip to content

Commit

Permalink
EPMRPP-98599 || Add truncate of instant with nanos to microseconds
Browse files Browse the repository at this point in the history
  • Loading branch information
pbortnik committed Jan 11, 2025
1 parent 5d82a07 commit b9f601f
Showing 1 changed file with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,14 @@ public Instant deserialize(JsonParser parser, DeserializationContext context) th
try {
long longDate = parser.getLongValue();
if (parser.getText() == null) {
return getTruncatedMillis(longDate);
return getTruncatedToMicros(longDate);
}
} catch (Exception e) {
// ignore
}
try {
long millis = Long.parseLong(parser.getText());
return getTruncatedMillis(millis);
long longDate = Long.parseLong(parser.getText());
return getTruncatedToMicros(longDate);
} catch (Exception e) {
// ignore
}
Expand All @@ -97,7 +97,7 @@ public Instant deserialize(JsonParser parser, DeserializationContext context) th
throw new IOException("Unable to parse date: " + strDate);
}

private Instant getTruncatedMillis(long value) {
return Instant.ofEpochMilli(value).truncatedTo(ChronoUnit.MICROS);
private Instant getTruncatedToMicros(long longDate) {
return Instant.ofEpochMilli(longDate).truncatedTo(ChronoUnit.MICROS);
}
}

0 comments on commit b9f601f

Please sign in to comment.