Here you can find the source of toString(LocalDateTime time)
public static String toString(LocalDateTime time)
//package com.java2s; //License from project: Apache License import java.text.SimpleDateFormat; import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; import java.util.Date; public class Main { public static String toString(LocalDateTime time) { return toString(time, "yyyy/MM/dd HH:mm:ss"); }/*from w ww . j a va2s. c o m*/ public static String toString(LocalDateTime time, String pattern) { DateTimeFormatter formatter = DateTimeFormatter.ofPattern(pattern); return time.format(formatter); } public static String toString(long time) { return toString(time, "yyyy/MM/dd HH:mm:ss"); } public static String toString(long time, String pattern) { SimpleDateFormat simpleDateFormat = new SimpleDateFormat(pattern); return simpleDateFormat.format(new Date(time)); } }