Java Long Number to Date formatDate(long ms)

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

Description

format Date

License

Apache License

Declaration

public static String formatDate(long ms) 

Method Source Code

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

import java.text.SimpleDateFormat;

import java.util.Date;

public class Main {
    public final static String defaultFormat = "yyyy-MM-dd HH:mm:ss";

    public static String formatDate(Date date) {
        return formatDate(date, defaultFormat);
    }//from  w  w w .j ava2 s  . co  m

    public static String formatDate(long ms) {
        return formatDate(new Date(ms), defaultFormat);
    }

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

Related

  1. formatDate(long millis)
  2. formatDate(long millis)
  3. formatDate(long millis, Locale locale)
  4. formatDate(long millis, String dateFormat)
  5. formatDate(long millisecond, String format)
  6. formatDate(long ms)
  7. formatDate(long p_millis)
  8. formatDate(long t)
  9. formatDate(long time)