parse LocalDateTime To String in format dd/MM/yyyy HH:mm - Java java.time

Java examples for java.time:LocalDateTime

Description

parse LocalDateTime To String in format dd/MM/yyyy HH:mm

Demo Code


//package com.java2s;
import java.time.DateTimeException;
import java.time.LocalDateTime;

import java.time.format.DateTimeFormatter;

public class Main {
    private static final DateTimeFormatter DATE_TIME_FORMATTER = DateTimeFormatter
            .ofPattern("dd/MM/yyyy HH:mm");

    public static String parseDateTimeToString(LocalDateTime inputDateTime) {
        try {//from   w w  w.j  av  a 2s  .  c  o m
            return inputDateTime.format(DATE_TIME_FORMATTER);
        } catch (DateTimeException e) {
            return null;
        }
    }
}

Related Tutorials