Skip to content

Commit

Permalink
Støtter region id.
Browse files Browse the repository at this point in the history
  • Loading branch information
ramrock93 committed Aug 16, 2024
1 parent f679405 commit 000a5cf
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,20 @@
public class CustomZonedDateTimeDeSerializer extends JsonDeserializer<ZonedDateTime> {

static final DateTimeFormatter zonedDateTimeFormatter = new DateTimeFormatterBuilder()
// 2024-08-14T10:05:56
.appendPattern("yyyy-MM-dd'T'HH:mm:ss")
.optionalStart()
// 2024-08-14T10:05:56.111
.appendFraction(ChronoField.MILLI_OF_SECOND, 0, 9, true)
.optionalEnd()
// 2024-08-14T10:05:56.111+02:00
.appendPattern("ZZZZZ")
.optionalStart()
// 2024-08-14T10:05:56.111+02:00[Europe/Oslo]
.appendLiteral('[')
.appendZoneRegionId()
.appendLiteral(']')
.optionalEnd()
.toFormatter();

@Override
Expand Down
1 change: 1 addition & 0 deletions soknad/src/test/java/no/nav/k9/søknad/JsonUtilsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ public void skal_kunne_deserialisere_zoneddatetime(String dato) {
"2024-08-14T10:05:56.1Z",
"2024-08-14T10:05:56Z",
"2024-08-14T10:05:56.111+02:00",
"2024-08-14T10:05:56.111+02:00[Europe/Oslo]",
})
public void deserialisering_av_zdt_skal_ikke_feile(String dato) {
assertThatNoException().isThrownBy(() -> ZonedDateTime.parse(dato, CustomZonedDateTimeDeSerializer.zonedDateTimeFormatter));
Expand Down

0 comments on commit 000a5cf

Please sign in to comment.