Skip to content

Instantly share code, notes, and snippets.

@nioe
Created June 4, 2015 11:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nioe/1dc6851de6e8b111a9d1 to your computer and use it in GitHub Desktop.
Save nioe/1dc6851de6e8b111a9d1 to your computer and use it in GitHub Desktop.
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