Format a LocalDate, an OffsetDateTime, and ZonedDateTime using ISO_DATE format
import java.time.LocalDate; import java.time.OffsetDateTime; import java.time.ZonedDateTime; import java.time.format.DateTimeFormatter; public class Main { public static void main(String[] args) { String ldStr = DateTimeFormatter.ISO_DATE.format(LocalDate.now()); String odtStr = DateTimeFormatter.ISO_DATE.format(OffsetDateTime.now()); String zdtStr = DateTimeFormatter.ISO_DATE.format(ZonedDateTime.now()); System.out.println("Local Date; " + ldStr); System.out.println("Offset Datetime: " + odtStr); System.out.println("Zoned Datetime: " + zdtStr); }//from ww w. j a v a2 s . co m }