Java Timestamp Format formatDateHour(Date date)

Here you can find the source of formatDateHour(Date date)

Description

format Date Hour

License

Apache License

Declaration

public static String formatDateHour(Date date) 

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 formatDateHour(Date date) {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        return sdf.format(date);
    }//from  www .  j a  va 2s .  co m

    public static String formatDateHour(Timestamp date) {
        if (date == null) {
            return "";
        }
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
        return sdf.format(date);
    }
}

Related

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