Java DateTimeFormatter formatDate(long milli)

Here you can find the source of formatDate(long milli)

Description

format Date

License

Mozilla Public License

Declaration

public static String formatDate(long milli) 

Method Source Code


//package com.java2s;
//License from project: Mozilla Public License 

import java.time.Instant;

import java.time.ZoneOffset;
import java.time.format.DateTimeFormatter;

public class Main {
    private static final ZoneOffset ZERO = ZoneOffset.ofTotalSeconds(0);

    public static String formatDate(long milli) {
        return DateTimeFormatter.ISO_LOCAL_DATE.format(Instant.ofEpochMilli(milli).atOffset(ZERO));
    }/* w w  w  . j av  a 2 s .c  o m*/

    public static String format(long milli) {
        return DateTimeFormatter.ISO_LOCAL_DATE_TIME.format(Instant.ofEpochMilli(milli).atOffset(ZERO));
    }
}

Related

  1. format(DateTimeFormatter formatter, Object object)
  2. format(long epochMilliSecond)
  3. formatAgo(long timestamp)
  4. formatByLocale(Date date, Locale locale)
  5. formatDate(long date)
  6. formatDate(long timestamp)
  7. formatDate(long timestamp)
  8. formatDateAndTime(String dateAndTime)
  9. formatDateTime(Date dateTime)