Java Date to String date2Str(Date date, String pattern)

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

Description

date Str

License

Open Source License

Declaration

public static String date2Str(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 DEFAULT_DATE_FORMAT = "yyyy-MM-dd";

    public static String date2Str(Date date, String pattern) {
        if (null == date) {
            return null;
        }/*from w w w. ja  v  a 2 s.c  o m*/
        if (null == pattern) {
            pattern = DEFAULT_DATE_FORMAT;
        }
        SimpleDateFormat format = new SimpleDateFormat();
        format.applyPattern(pattern);
        return format.format(date);
    }
}

Related

  1. date2Str(Date date)
  2. date2Str(Date date, String dateFormat)
  3. date2Str(Date date, String format)
  4. date2Str(Date date, String format)
  5. date2Str(Date date, String partten)
  6. date2Str(Date value)
  7. date2Str(final Date date, final String dateFormat)
  8. date2Str(SimpleDateFormat date_sdf)
  9. date2string(Date _aDate)