Skip to content
Home » Formatting a LocalDateTime object

Formatting a LocalDateTime object

gold and white analog watch

Here’s how to format a LocalDateTime object.

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

public final class LocalDateTimeFormatter {

    private static final DateTimeFormatter FORMATTER = DateTimeFormatter.ofPattern("dd/MM/yyyy HH:mm:ss");

    public static void main(String[] args) {
        LocalDateTime currentDateTime =;
        String formattedDateTime = currentDateTime.format(FORMATTER);


If you have any questions, leave a comment or ask me on my social media.