Java Hour Format format(Date date, String pattern)

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

Description

format

License

Open Source License

Declaration

public static String format(Date date, String pattern) 

Method Source Code

//package com.java2s;

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

public class Main {
    public static String YYYY_MM_DD_HH_MM_SS = "yyyy-MM-dd HH:mm:ss";
    public static final String DATE_PATTERN_SS = "yyyyMMddHHmmssSS";

    public static String format(Date date) {
        SimpleDateFormat sdf = new SimpleDateFormat(YYYY_MM_DD_HH_MM_SS);
        return sdf.format(date);
    }/*from www  .j a v  a2s  .  c o  m*/

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

    public static String format() {
        SimpleDateFormat sdf = new SimpleDateFormat(DATE_PATTERN_SS);
        return sdf.format(new Date());
    }
}

Related

  1. format(Date date)
  2. format(Date date)
  3. format(Date date, String dateFormat)
  4. format(Date date, String format)
  5. format(Date date, String format)
  6. format(Date date, String ptrn)
  7. format(Date dateTime)
  8. format(Date dt)
  9. format(Date self, String format, TimeZone tz)