Java examples for java.time:LocalDateTime
format LocalDateTime Date Time
import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatterBuilder; public class Main{ private static final DateTimeFormatter FMT = new DateTimeFormatterBuilder() .appendPattern(PATTERN).toFormatter(); public static String formatDateTime(LocalDateTime dateTime) { String text = ""; if (dateTime != null) { return dateTime.format(FMT); }//from w w w . j ava 2s . com return text; } }