Java LocalDateTime Format formatDateTime(LocalDateTime dateTime)

Here you can find the source of formatDateTime(LocalDateTime dateTime)

Description

Returns a string representing dateTime with DATE_TIME_FORMATTER

License

Open Source License

Parameter

Parameter Description
dateTime a parameter

Declaration

public static String formatDateTime(LocalDateTime dateTime) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

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

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

    /**//from  ww  w . j  a v a 2  s .c o m
     * Returns a string representing dateTime with DATE_TIME_FORMATTER
     * @param dateTime
     * @return 
     */
    public static String formatDateTime(LocalDateTime dateTime) {
        return dateTime.format(DATE_TIME_FORMATTER);
    }
}

Related

  1. format(LocalDateTime localDateTime, String pattern)
  2. formatDate(LocalDateTime dateTime)
  3. formatDate(String inPattern, LocalDateTime inTime)
  4. formatDateFromTo(LocalDateTime dateFrom, LocalDateTime dateTo)
  5. formatDateGeneric(DateTimeFormatter dateTimeFormatter, LocalDateTime localDateTime)
  6. formatDayOfMonth(LocalDateTime dateTime)
  7. formatLocalDateTimeToString(LocalDateTime date)
  8. formatShortDate(LocalDateTime dateTime)
  9. formattedWeek(LocalDateTime localDateTime)