Saturday, 4 April 2015

xml adapter combining 2 xml elements



I have an xml file with these elements:



<showing>
<id type="integer">1</id>
<date type="date">2015-05-22</date>
<time type="dateTime">2000-01-01T19:45:00Z</time>
<movie-id type="integer">1</movie-id>
<screen-id type="integer">1</screen-id>-
</showing>


I have a showing class to acces these elements, this class works perfectly for id, movie-id and screen-id. Now I want to use the following method to get a LocalDateTime.



@XmlJavaTypeAdapter(ConnectAdapter.class)
public LocalDateTime getTime() {
return time;
}

public void setTime(LocalDateTime time){
this.time = time;
}


The LocalDateTime must be a combination of the date element in the xml file and the time element, only using the time(19:45:00 in this example). So the result should be a LocalDateTime 2015-05-22T19:45:00 for this example.


I tried to do this with an xml adapter class, but I don't get any good results. Is there a way that this method can read 2 elements from an xml file and returns a combined result?


No comments:

Post a Comment