Commit c1d98642 by Patryk Czarnik

DateTimeAdapter

parent ca305643
package sklep.model;
import java.time.LocalDateTime;
import jakarta.xml.bind.annotation.adapters.XmlAdapter;
public class DateTimeAdapter extends XmlAdapter<String, LocalDateTime> {
@Override
public String marshal(LocalDateTime dt) throws Exception {
return dt.toString();
}
@Override
public LocalDateTime unmarshal(String s) throws Exception {
return LocalDateTime.parse(s);
}
}
......@@ -10,6 +10,7 @@ import java.util.Objects;
import jakarta.xml.bind.annotation.XmlAttribute;
import jakarta.xml.bind.annotation.XmlElement;
import jakarta.xml.bind.annotation.XmlElementWrapper;
import jakarta.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
public class Order {
@XmlAttribute(name="id")
......@@ -19,6 +20,7 @@ public class Order {
private String customerEmail;
@XmlElement(name="order-date")
@XmlJavaTypeAdapter(DateTimeAdapter.class)
private LocalDateTime orderDate;
@XmlAttribute(name="status")
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment