Here you can find the source of serialize(LocalDateTime date)
public static String serialize(LocalDateTime date)
//package com.java2s; //License from project: Apache License import java.time.LocalDateTime; import java.time.ZoneId; import java.time.format.DateTimeFormatter; import java.util.Date; public class Main { private static final DateTimeFormatter ISO_FORMAT = DateTimeFormatter.ISO_LOCAL_DATE_TIME; public static final ZoneId UTC = ZoneId.of("UTC"); public static String serialize(LocalDateTime date) { return date.format(ISO_FORMAT); }// w w w . ja va2 s . c o m public static String serialize(Date date) { return serialize(fromUtilDate(date)); } public static LocalDateTime fromUtilDate(Date date) { if (date.getClass() == Date.class) { return LocalDateTime.ofInstant(date.toInstant(), UTC); } return fromUtilDate(new Date(date.getTime())); //hack for old java.sql.Date } }