Posts

Showing posts with the label jaxb

jaxb unmarshal xml element to object with some fields

Image
Clash Royale CLAN TAG #URR8PPP jaxb unmarshal xml element to object with some fields I have some classes: class Location { private Long id; private String roomTitle; protected Specialization specialization; } public class Specialization { private Long id; private boolean archived; private String title; } and xml: <location id="10"> <roomTitle>string</roomTitle> <specializationId>10</specializationId> </location> Can I unmarshal specializationId to Location.specialization.id ? By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Unexpected values when unmarshalling data and currency attributes using JAXB

Image
Clash Royale CLAN TAG #URR8PPP Unexpected values when unmarshalling data and currency attributes using JAXB I am trying to umarshall xml response to java pojo. Having issues with date and currency values while unmarshalling using jaxb Results of unmarshalling, the currency field value not getting mapped(null) and date field is mapped to some numbers(like 1503979200000) Could someone please let me know where I am going wrong? Thanks in advance for your help. Below is my code: @XmlRootElement( name = "item" ) @XmlAccessorType(XmlAccessType.FIELD) public class Item{ @XmlElement( name = "bl" ) @XmlJavaTypeAdapter(DateTimeAdapter.class) private Date docDate; @XmlElement( name = "sd" ) @XmlJavaTypeAdapter(DateTimeAdapter.class) private Date dueDate; @XmlElement( name = "bu" ) @XmlJavaTypeAdapter(DateTimeAdapter.class) private Date postingDate; @XmlElement( name = "wr" ) @XmlJavaTypeAdapter(CurrencyAdapter.class) private Currency ...