Java Long Number to Date formatDateTime(long date)

Here you can find the source of formatDateTime(long date)

Description

format Date Time

License

Apache License

Declaration

public static String formatDateTime(long date) 

Method Source Code

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

import java.text.SimpleDateFormat;

import java.util.Date;

public class Main {
    private static final String DEFAULT_DATE_PATTERN = "yyyy-MM-dd";
    private static final String DEFAULT_DATETIME_PATTERN = "yyyy-MM-dd hh:mm:ss";

    public static String formatDateTime(Date date) {
        return formatDate(date, DEFAULT_DATETIME_PATTERN);
    }//  w  ww .j ava2s.co m

    public static String formatDateTime(long date) {
        return formatDate(new Date(date), DEFAULT_DATETIME_PATTERN);
    }

    public static String formatDate(Date date, String pattern) {
        SimpleDateFormat format = new SimpleDateFormat(pattern);
        return format.format(date);
    }

    public static String formatDate(Date date) {
        return formatDate(date, DEFAULT_DATE_PATTERN);
    }

    /**
     * @param date long: 141536480014L
     * @return
     */
    public static String formatDate(long date) {
        return formatDate(new Date(date), DEFAULT_DATE_PATTERN);
    }
}

Related

  1. formatDateHeader(long millis)
  2. formatDateHeader(long value)
  3. formatDateISO(long millis)
  4. formatDateTime(long d)
  5. formatDateTime(long d)
  6. formatDateTime(long millis)
  7. formatDateTime(long time)
  8. formatDateTime(long timestampEpoch)
  9. formatDateTimeStamp(final long timeInMillis, final String dateFormatString)