Java LocalDateTime to toString(LocalDateTime time)

Here you can find the source of toString(LocalDateTime time)

Description

to String

License

Apache License

Declaration

public static String toString(LocalDateTime time) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.text.SimpleDateFormat;
import java.time.LocalDateTime;

import java.time.format.DateTimeFormatter;
import java.util.Date;

public class Main {
    public static String toString(LocalDateTime time) {
        return toString(time, "yyyy/MM/dd HH:mm:ss");
    }/*from   w ww .  j a  va2s.  c  o  m*/

    public static String toString(LocalDateTime time, String pattern) {
        DateTimeFormatter formatter = DateTimeFormatter.ofPattern(pattern);
        return time.format(formatter);
    }

    public static String toString(long time) {
        return toString(time, "yyyy/MM/dd HH:mm:ss");
    }

    public static String toString(long time, String pattern) {
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat(pattern);
        return simpleDateFormat.format(new Date(time));
    }
}

Related

  1. toDateUTCFromJST(LocalDateTime dateTime)
  2. toJava8(org.joda.time.LocalDateTime x)
  3. toJsonDate(LocalDateTime date)
  4. tokenExpired(LocalDateTime expiryDate)
  5. toMinuteCount(LocalDateTime ldt)
  6. toStringIfPresent(LocalDateTime dateTime)
  7. toUtilDate(LocalDateTime localDateTime)
  8. validateTime(LocalDateTime timestamp)