Skip to content

Commit

Permalink
improved jdk8 java.time support
Browse files Browse the repository at this point in the history
  • Loading branch information
wenshao committed May 2, 2022
1 parent c63866e commit cd3c2de
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,6 @@ public <T> T deserialze(DefaultJSONParser parser, Type type, Object fieldName, S
return (T) period;
} else if (type == Duration.class) {
Duration duration = Duration.parse(text);

return (T) duration;
} else if (type == Instant.class) {
boolean digit = true;
Expand Down Expand Up @@ -249,6 +248,12 @@ public <T> T deserialze(DefaultJSONParser parser, Type type, Object fieldName, S
return (T) Instant.ofEpochSecond(
TypeUtils.longExtractValue((Number) epochSecond));
}
} else if (type == Duration.class) {
Long seconds = object.getLong("seconds");
if (seconds != null) {
long nanos = object.getLongValue("nano");
return (T) Duration.ofSeconds(seconds, nanos);
}
}
} else {
throw new UnsupportedOperationException();
Expand Down

0 comments on commit cd3c2de

Please sign in to comment.