You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@isis.apache.org by "ASF subversion and git services (JIRA)" <ji...@apache.org> on 2018/10/15 09:06:00 UTC
[jira] [Commented] (ISIS-1972) JAXB view model: add default
XmlAdapters for Java 8 Time
[ https://issues.apache.org/jira/browse/ISIS-1972?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16649929#comment-16649929 ]
ASF subversion and git services commented on ISIS-1972:
-------------------------------------------------------
Commit 9b0744274af2172c89eb668883a106f6c4dd1349 in isis's branch refs/heads/v2 from [~hobrom]
[ https://gitbox.apache.org/repos/asf?p=isis.git;h=9b07442 ]
ISIS-1972: Moving JaxbAdapters into better suited 'util' package
Task-Url: https://issues.apache.org/jira/browse/ISIS-1972
> JAXB view model: add default XmlAdapters for Java 8 Time
> --------------------------------------------------------
>
> Key: ISIS-1972
> URL: https://issues.apache.org/jira/browse/ISIS-1972
> Project: Isis
> Issue Type: Improvement
> Components: Core
> Affects Versions: 2.0.0-M1
> Reporter: Andi Huber
> Assignee: Andi Huber
> Priority: Major
> Fix For: 2.0.0-M2
>
>
> see https://stackoverflow.com/questions/36156741/marshalling-localdate-using-jaxb
> sample code:
> {code:java}
> // DOMAIN CODE
> @XmlRootElement(name = "Demo")
> @XmlType
> @XmlAccessorType(XmlAccessType.FIELD)
> @DomainObject(nature=Nature.VIEW_MODEL, editing=Editing.ENABLED)
> @Log
> public class TemporalDemo extends DemoStub {
> @PostConstruct
> public void initDefaults() {
>
> log.info("TemporalDemo::initDefaults");
>
> javaLocalDate = LocalDate.now();
> javaLocalDateTime = LocalDateTime.now();
> }
>
> @XmlJavaTypeAdapter(value = LocalDateAdapter.class)
> @XmlElement @Getter @Setter private LocalDate javaLocalDate;
>
> @XmlJavaTypeAdapter(value = LocalDateTimeAdapter.class)
> @XmlElement @Getter @Setter private LocalDateTime javaLocalDateTime;
>
> }
> // COULD BE PART OF CORE
> public final class JaxbAdapters {
>
> public static final class LocalDateAdapter extends XmlAdapter<String, LocalDate>{
> public LocalDate unmarshal(String v) throws Exception {
> return LocalDate.parse(v);
> }
> public String marshal(LocalDate v) throws Exception {
> return v.toString();
> }
> }
>
> public static final class LocalDateTimeAdapter extends XmlAdapter<String, LocalDateTime>{
> public LocalDateTime unmarshal(String v) throws Exception {
> return LocalDateTime.parse(v);
> }
> public String marshal(LocalDateTime v) throws Exception {
> return v.toString();
> }
> }
> ...
>
> }
> {code}
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)