Skip to content

Commit

Permalink
Support for Java 8 Date/Time API in parameters #125
Browse files Browse the repository at this point in the history
add support java.sql.Time
  • Loading branch information
plakhov committed Mar 3, 2021
1 parent 52a0dd5 commit 9f41585
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,11 @@ public Object toObject(Type type, String value, @Nullable String modelVersion) t
return Datatypes.getNN(OffsetTime.class).parse(value);
}
if (Time.class == clazz) {
return Datatypes.getNN(Time.class).parse(value);
LocalTime result = Datatypes.getNN(LocalTime.class).parse(value);
if (result == null) {
return null;
}
return Time.valueOf(result);
}
if (BigDecimal.class == clazz) return Datatypes.getNN(BigDecimal.class).parse(value);
if (Boolean.class == clazz || Boolean.TYPE == clazz) return Datatypes.getNN(Boolean.class).parse(value);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public String convertDate(LocalDate localDate, LocalDateTime localDateTime, Loca
builder.append(localDateTime.toString()).append(",");
builder.append(localTime.toString()).append(",");
builder.append(offsetDateTime.toString()).append(",");
builder.append(offsetTime.toString());
builder.append(offsetTime.toString()).append(",");
builder.append(time.toString());
return builder.toString();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public void serviceWithDateParams() throws Exception {
String requestBody = getFileContent("serviceWithDateParams.json", null);
try (CloseableHttpResponse response = sendPost("/services/" + PortalTestService.NAME + "/convertDate", oauthToken, requestBody, null)) {
assertEquals(HttpStatus.SC_OK, statusCode(response));
assertEquals("2021-02-24,2021-02-24T15:15:15.053,15:15:15,2021-02-24T15:15:15.053+04:00,15:15:15+04:00", responseToString(response));
assertEquals("2021-02-24,2021-02-24T15:15:15.053,15:15:15,2021-02-24T15:15:15.053+04:00,15:15:15+04:00,15:15:15", responseToString(response));
}
}

Expand Down

0 comments on commit 9f41585

Please sign in to comment.