Java Date to String dateToString(Date date, String format)

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

Description

date To String

License

Open Source License

Parameter

Parameter Description
date a parameter

Declaration

public static String dateToString(Date date, String format) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.text.DateFormat;

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

public class Main {
    /**/* w  ww .j  a  v  a2 s  . co m*/
     * @param date
     * @return
     */
    public static String dateToString(Date date, String format) {

        if (date == null) {
            return null;
        }
        DateFormat dateFormat = new SimpleDateFormat(format);
        dateFormat.setLenient(true);
        return dateFormat.format(date);
    }
}

Related

  1. dateToString(Date date)
  2. dateToString(Date date)
  3. dateToString(Date date)
  4. dateToString(Date date, String dateFormat)
  5. dateToString(Date date, String formartStr)
  6. dateToString(Date date, String format)
  7. dateToString(Date date, String format)
  8. dateToString(Date date, String format)
  9. dateToString(Date date, String format)