Java Date Format dateFormat(Date date, String pattern)

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

Description

date Format

License

Open Source License

Declaration

public static String dateFormat(Date date, String pattern) 

Method Source Code

//package com.java2s;

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

public class Main {
    public static final String DATE_PATTERN = "yyyy-MM-dd";

    public static String dateFormat(Date date, String pattern) {
        if (pattern == null || "".equals(pattern.trim())) {
            pattern = DATE_PATTERN;/*from w  w w .j  a va  2  s .  c o  m*/
        }
        SimpleDateFormat sdf = new SimpleDateFormat(pattern);
        return sdf.format(date);
    }
}

Related

  1. dateFormat(Date date)
  2. dateFormat(Date date)
  3. dateFormat(Date date)
  4. dateFormat(Date date, String format)
  5. dateFormat(Date date, String format)
  6. dateFormat(Date date, String pattern)
  7. dateFormat(Date date, String pattern)
  8. dateFormat(DateFormat f, Date d)
  9. dateFormat(int grain, TimeZone timeZone)