I want to Change Date Format

This is utilizing the new date and formatter classes in Java 8:

LocalDateTime date = LocalDate.of(2015, Month.JULY, 3);
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dMMM yyyy");
String formattedDateTime = date.format(formatter); // "3Aug 2015"

Leave a Comment