-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add custom mappings for LocalDate and LocalDateTime
Introduced new classes LocalDateCustomMapping and LocalDateTimeCustomMapping to handle custom conversion formats. Updated OppdragRequest and related mapping strategies to use these custom converters. Added unit tests to verify the new mapping logic.
- Loading branch information
Showing
6 changed files
with
329 additions
and
28 deletions.
There are no files selected for viewing
23 changes: 23 additions & 0 deletions
23
...ag-service/src/main/java/no/nav/testnav/oppdragservice/mapper/LocalDateCustomMapping.java
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,23 @@ | ||
package no.nav.testnav.oppdragservice.mapper; | ||
|
||
import lombok.extern.slf4j.Slf4j; | ||
import ma.glasnost.orika.CustomConverter; | ||
import ma.glasnost.orika.MappingContext; | ||
import ma.glasnost.orika.metadata.Type; | ||
import org.springframework.stereotype.Component; | ||
|
||
import java.time.LocalDate; | ||
import java.time.format.DateTimeFormatter; | ||
|
||
@Slf4j | ||
@Component | ||
public class LocalDateCustomMapping extends CustomConverter<LocalDate, String> { | ||
|
||
private static final DateTimeFormatter FORMATTER = DateTimeFormatter.ofPattern("dd-MM-yyyy"); | ||
|
||
@Override | ||
public String convert(LocalDate localDate, Type<? extends String> type, MappingContext mappingContext) { | ||
|
||
return FORMATTER.format(localDate); | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
...ervice/src/main/java/no/nav/testnav/oppdragservice/mapper/LocalDateTimeCustomMapping.java
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,23 @@ | ||
package no.nav.testnav.oppdragservice.mapper; | ||
|
||
import lombok.extern.slf4j.Slf4j; | ||
import ma.glasnost.orika.CustomConverter; | ||
import ma.glasnost.orika.MappingContext; | ||
import ma.glasnost.orika.metadata.Type; | ||
import org.springframework.stereotype.Component; | ||
|
||
import java.time.LocalDateTime; | ||
import java.time.format.DateTimeFormatter; | ||
|
||
@Slf4j | ||
@Component | ||
public class LocalDateTimeCustomMapping extends CustomConverter<LocalDateTime, String> { | ||
|
||
private static final DateTimeFormatter FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd-HH.mm.ss.SSSSSS"); | ||
|
||
@Override | ||
public String convert(LocalDateTime localDateTime, Type<? extends String> type, MappingContext mappingContext) { | ||
|
||
return FORMATTER.format(localDateTime); | ||
} | ||
} |
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
Oops, something went wrong.