-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
29 additions
and
1 deletion.
There are no files selected for viewing
23 changes: 23 additions & 0 deletions
23
src/main/java/no/digipost/api/datatypes/marshalling/LocalDateXmlAdapter.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.digipost.api.datatypes.marshalling; | ||
|
||
import jakarta.xml.bind.annotation.adapters.XmlAdapter; | ||
|
||
import java.time.LocalDate; | ||
public class LocalDateXmlAdapter extends XmlAdapter<String, LocalDate> { | ||
@Override | ||
public String marshal(LocalDate v) { | ||
if (v == null) { | ||
return null; | ||
} | ||
return v.toString(); | ||
} | ||
|
||
@Override | ||
public LocalDate unmarshal(final String s) { | ||
if (s == null) { | ||
return null; | ||
} | ||
return LocalDate.parse(s); | ||
} | ||
|
||
} |
7 changes: 6 additions & 1 deletion
7
src/main/java/no/digipost/api/datatypes/types/invoice/package-info.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 |
---|---|---|
@@ -1,14 +1,19 @@ | ||
@XmlSchema(namespace = DIGIPOST_DATATYPES_NAMESPACE, elementFormDefault = jakarta.xml.bind.annotation.XmlNsForm.QUALIFIED) | ||
@XmlAccessorType(XmlAccessType.FIELD) | ||
@XmlJavaTypeAdapter(ZonedDateTimeXmlAdapter.class) | ||
@XmlJavaTypeAdapters({ | ||
@XmlJavaTypeAdapter(ZonedDateTimeXmlAdapter.class), | ||
@XmlJavaTypeAdapter(LocalDateXmlAdapter.class) | ||
}) | ||
@DataTypePackage | ||
package no.digipost.api.datatypes.types.invoice; | ||
|
||
import jakarta.xml.bind.annotation.XmlAccessType; | ||
import jakarta.xml.bind.annotation.XmlAccessorType; | ||
import jakarta.xml.bind.annotation.XmlSchema; | ||
import jakarta.xml.bind.annotation.adapters.XmlJavaTypeAdapter; | ||
import jakarta.xml.bind.annotation.adapters.XmlJavaTypeAdapters; | ||
import no.digipost.api.datatypes.documentation.DataTypePackage; | ||
import no.digipost.api.datatypes.marshalling.LocalDateXmlAdapter; | ||
import no.digipost.api.datatypes.marshalling.ZonedDateTimeXmlAdapter; | ||
|
||
import static no.digipost.api.datatypes.marshalling.DataTypesJAXBContext.DIGIPOST_DATATYPES_NAMESPACE; |