Java Date to String date2String(Date date, DateFormat dateFormat)

Here you can find the source of date2String(Date date, DateFormat dateFormat)

Description

date String

License

Open Source License

Declaration

public synchronized static String date2String(Date date, DateFormat dateFormat) 

Method Source Code

//package com.java2s;

import java.text.DateFormat;

import java.text.SimpleDateFormat;

import java.util.Date;

public class Main {
    public static final DateFormat DEFAULT_DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd");

    public synchronized static String date2String(Date date, DateFormat dateFormat) {
        if (date == null)
            return null;
        return dateFormat.format(date);
    }/*from   w w w.j av  a2  s.c  o m*/

    public static String date2String(Date date, String dateFormat) {
        if (date == null)
            return null;
        return date2String(date, new SimpleDateFormat(dateFormat));
    }

    public static String date2String(Date date) {
        if (date == null)
            return null;
        return date2String(date, DEFAULT_DATE_FORMAT);
    }
}

Related

  1. date2String(Date date)
  2. date2string(Date date)
  3. date2String(Date date)
  4. date2String(Date date)
  5. date2String(Date date)
  6. date2String(Date date, int _iType)
  7. Date2String(Date date, String DateFormat)
  8. date2string(Date date, String format)
  9. date2String(Date date, String format)