Java examples for java.time:Format
format LocalDate as ISO_LOCAL_DATE_TIME
//package com.java2s; import java.time.LocalDate; import java.time.format.DateTimeFormatter; import java.util.Optional; public class Main { private static DateTimeFormatter DEFAULT_DATE_FORMATTER = DateTimeFormatter.ISO_LOCAL_DATE_TIME; public static Optional<String> formatLocalDate(LocalDate date) { if (null == date) { return Optional.empty(); }/*from www . j a v a 2 s .c o m*/ return Optional.of(DEFAULT_DATE_FORMATTER.format(date)); } }