Java Hour Format formatDateTime(Date date)

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

Description

Format the Date object to string with format "yyyy-MM-dd HH:mm:ss"

License

Apache License

Parameter

Parameter Description
date a parameter

Declaration

public static final String formatDateTime(Date 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 SimpleDateFormat SDF_DETAIL = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

    /**//w w  w.  ja  va 2  s.c o  m
     * Format the Date object to string with format "yyyy-MM-dd HH:mm:ss"
     * @param date
     * @return
     */
    public static final String formatDateTime(Date date) {
        if (date != null) {
            synchronized (SDF_DETAIL) {
                return SDF_DETAIL.format(date);
            }
        } else {
            return null;
        }
    }
}

Related

  1. formatDateTime(Date date)
  2. formatDateTime(Date date)
  3. formatDateTime(Date date)
  4. formatDateTime(Date date)
  5. formatDateTime(Date date)
  6. formatDateTime(Date date)
  7. formatDateTime(Date date)
  8. formatDateTime(Date date)
  9. formatDatetime(Date date)