Created
June 4, 2015 11:30
-
-
Save nioe/1dc6851de6e8b111a9d1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package ch.exq.triplog.server.util.json; | |
import javax.xml.bind.annotation.adapters.XmlAdapter; | |
import java.time.LocalDateTime; | |
import java.time.format.DateTimeFormatter; | |
public class JsonDateTimeAdapter extends XmlAdapter<String, LocalDateTime> { | |
private static final DateTimeFormatter FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); | |
@Override | |
public LocalDateTime unmarshal(String v) throws Exception { | |
return LocalDateTime.parse(v, FORMATTER); | |
} | |
@Override | |
public String marshal(LocalDateTime v) throws Exception { | |
return v.format(FORMATTER); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment