net.finmath.smartcontract.settlement.ZonedDateTimeAdapter Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of finmath-smart-derivative-contract Show documentation
Show all versions of finmath-smart-derivative-contract Show documentation
Project to support the implementation a of smart derivative contract.
package net.finmath.smartcontract.settlement;
import jakarta.xml.bind.annotation.adapters.XmlAdapter;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;
public class ZonedDateTimeAdapter extends XmlAdapter {
@Override
public String marshal(ZonedDateTime v) {
return v.format(DateTimeFormatter.ofPattern("yyyyMMdd-HHmmss"));
}
@Override
public ZonedDateTime unmarshal(String str) {
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMMdd-HHmmss");
LocalDateTime ldt = LocalDateTime.parse(str, formatter);
return ZonedDateTime.of(ldt, ZoneId.systemDefault());
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy