it.bz.opendatahub.alpinebits.xml.xmladapter.LocalDateAdapter Maven / Gradle / Ivy
/*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
package it.bz.opendatahub.alpinebits.xml.xmladapter;
import javax.xml.bind.annotation.adapters.XmlAdapter;
import java.time.LocalDate;
/**
* XML adapter to convert xs:date values to {@link LocalDate}.
*/
public class LocalDateAdapter extends XmlAdapter {
@Override
public LocalDate unmarshal(String v) {
return LocalDate.parse(v);
}
@Override
public String marshal(LocalDate v) {
return v != null ? v.toString() : null;
}
}