Java Hour Format formatDate(Date date, String format)

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

Description

format Date

License

Apache License

Declaration

public static String formatDate(Date date, String format) 

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 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

    public static String formatDate() {
        return ((SimpleDateFormat) sdf.clone()).format(new Date());
    }/*from  www . j a  v  a  2  s .c  o  m*/

    public static String formatDate(Date date) {
        return date != null ? ((SimpleDateFormat) sdf.clone()).format(date) : null;
    }

    public static String formatDate(Date date, String format) {
        return date != null && format != null ? new SimpleDateFormat(format).format(date) : null;
    }
}

Related

  1. formatDate(Date date, String expression)
  2. formatDate(Date date, String format)
  3. formatDate(Date date, String format)
  4. formatDate(Date date, String format)
  5. formatDate(Date date, String format)
  6. formatDate(Date date, String format, Locale locale)
  7. formatDate(Date date, String patter)
  8. formatDate(Date date, String pattern)
  9. formatDate(Date date, String pattern)