Java DateTimeFormatter formatDate(long timestamp)

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

Description

format Date

License

Apache License

Declaration

public static String formatDate(long timestamp) 

Method Source Code


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

import java.time.*;
import java.time.format.DateTimeFormatter;

public class Main {
    protected static final ZoneId UTC_ZONE = ZoneId.of("UTC");
    protected static final DateTimeFormatter DATE_PARSER_FORMATTER = DateTimeFormatter.ofPattern("uuuuMMdd");

    public static String formatDate(long timestamp) {
        return Instant.ofEpochMilli(timestamp).atZone(UTC_ZONE).format(DATE_PARSER_FORMATTER);
    }/*from  w w  w .j  ava  2s.  c o  m*/
}

Related

  1. formatAgo(long timestamp)
  2. formatByLocale(Date date, Locale locale)
  3. formatDate(long date)
  4. formatDate(long milli)
  5. formatDate(long timestamp)
  6. formatDateAndTime(String dateAndTime)
  7. formatDateTime(Date dateTime)
  8. formatDateTime(long milis)
  9. formatISOUTCDateTime(long timestamp)