Java Timestamp Format formatDate(Timestamp time)

Here you can find the source of formatDate(Timestamp time)

Description

format Date

License

Apache License

Declaration

public static String formatDate(Timestamp time) 

Method Source Code


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

import java.sql.Timestamp;

import java.text.SimpleDateFormat;
import java.util.Date;

public class Main {
    public static String formatDate(Timestamp time) {
        return formatDate(new java.util.Date(time.getTime()));
    }//from  w w  w  . j  a va 2 s.  co  m

    public static String formatDate(java.sql.Date date) {
        return formatDate(new java.util.Date(date.getTime()));
    }

    public static String formatDate(Date date) {
        return formatDate(date, "yyyy-MM-dd HH:mm:ss");
    }

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

Related

  1. formatDate(Date date, String pattern)
  2. formatDate(java.sql.Timestamp timestamp)
  3. formatDate(java.util.Date d)
  4. formatDate(java.util.Date date)
  5. formatDate(Timestamp date)
  6. formatDate(Timestamp time, String pattern)
  7. formatDate(Timestamp timestamp)
  8. formatDateHour(Date date)
  9. formatDateTime(Date date)