20 lines
588 B
Java
20 lines
588 B
Java
package at.technikumwien.movies;
|
|
|
|
import javax.xml.bind.annotation.adapters.XmlAdapter;
|
|
import java.time.LocalDate;
|
|
import java.time.format.DateTimeFormatter;
|
|
|
|
public class LocalDateAdapter extends XmlAdapter<String, LocalDate> {
|
|
private static final DateTimeFormatter FORMATTER = DateTimeFormatter.ofPattern("dd.MM.yyyy");
|
|
|
|
@Override
|
|
public LocalDate unmarshal(String s) throws Exception {
|
|
return LocalDate.parse(s, FORMATTER);
|
|
}
|
|
|
|
@Override
|
|
public String marshal(LocalDate localDate) throws Exception {
|
|
return FORMATTER.format(localDate);
|
|
}
|
|
}
|