Java Hour Format format(Date date, String dateFormat)

Here you can find the source of format(Date date, String dateFormat)

Description

format

License

Apache License

Declaration

public static String format(Date date, String dateFormat) 

Method Source Code

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

import java.text.SimpleDateFormat;

import java.util.Date;

public class Main {
    /**/*from www .  j  a v  a2 s.  c om*/
     * yyyy-MM-dd HH:mm:ss
     */
    public static final String DATETIME_FORMAT = "yyyy-MM-dd HH:mm:ss";

    public static String format(Date date) {
        return format(date, DATETIME_FORMAT);
    }

    public static String format(Date date, String dateFormat) {
        if (date != null) {
            SimpleDateFormat format = new SimpleDateFormat(dateFormat);
            String dateString = format.format(date);
            return dateString;
        }
        return null;
    }
}

Related

  1. format(Date date)
  2. format(Date date)
  3. format(Date date)
  4. format(Date date)
  5. format(Date date)
  6. format(Date date, String format)
  7. format(Date date, String format)
  8. format(Date date, String pattern)
  9. format(Date date, String ptrn)