Java Long Number to Date formatDate(long timestamp, String format)

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

Description

format Date

License

Open Source License

Declaration

public static String formatDate(long timestamp, String format) 

Method Source Code

//package com.java2s;

import java.text.SimpleDateFormat;
import java.util.*;

public class Main {

    public static String formatDate(Date date, String format) {
        if (format == null || "".equals(format)) {
            format = "yyyy-MM-dd HH:mm:ss";
        }/*  w  w w  .  j  ava2 s .c o m*/
        SimpleDateFormat sdf = new SimpleDateFormat(format);
        return sdf.format(date);
    }

    public static String formatDate(long timestamp, String format) {
        if (format == null || "".equals(format)) {
            format = "yyyy-MM-dd HH:mm:ss";
        }
        SimpleDateFormat sdf = new SimpleDateFormat(format);
        return sdf.format(new Date(timestamp));
    }
}

Related

  1. formatDate(long time)
  2. formatDate(long time)
  3. formatDate(long time, String format)
  4. formatDate(long time_millis)
  5. formatDate(long timeStamp)
  6. formatDate(String format, long timestamp)
  7. formatDate2DateStr(long date)
  8. formatDate2DateStr(long date)
  9. formatDateForLog(long dateTs)