Java LocalDateTime Format toString(LocalDateTime ldt, DateTimeFormatter formatter)

Here you can find the source of toString(LocalDateTime ldt, DateTimeFormatter formatter)

Description

to String

License

Open Source License

Declaration

public static String toString(LocalDateTime ldt, DateTimeFormatter formatter) 

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");

    public static String toString(LocalDateTime ldt) {
        return toString(ldt, DATE_TIME_FORMATTER);
    }//from   ww w  .  ja v a  2  s. co  m

    public static String toString(LocalDateTime ldt, DateTimeFormatter formatter) {
        return ldt == null ? "" : ldt.format(formatter);
    }
}

Related

  1. formatTime(LocalDateTime dateTime)
  2. formatTime(LocalDateTime time)
  3. localDateTime2Str(LocalDateTime localDateTime, String dateTimeFormatter)
  4. toDoubleExcelFormat(LocalDateTime date, boolean date1904)
  5. toLocalDateTime(String date, DateTimeFormatter formatter)