Formatting LocalDate object as a string

LocalDate is a class with many features which can be used to create date and time in Java. It was introduced in Java 8. The class SimpleDateFormat cannot be used with LocalDate.

LocalDate object can be formatted with the class DateTimeFormatter. First create a LocalDate object with the current date.

LocalDate localDateObject =;

Then create a DateTimeFormatter object to format the date as you wish.

DateTimeFormatter dtformat = DateTimeFormatter.ofPattern("dd.MM.yyyy");

"MM" stands for month. But "mm" stands for minute.


The DateTimeFormatter object can be called through this method directly.

String dateString = localDateObject.format(dtformat);

More information about the class "DateTimeFormatter":



Cookies make it easier for us to provide you with our services. With the usage of our services you permit us to use cookies.