Java Date to String date2string(Date date)

Here you can find the source of date2string(Date date)

Description

datestring

License

Open Source License

Declaration

public static String date2string(Date date) 

Method Source Code

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

import java.text.SimpleDateFormat;

import java.util.Date;

public class Main {

    public static String date2string(Date date) {
        return date2string(date, "yyyy-MM-dd HH:mm:ss");
    }/* w w  w  .  j  a v a 2 s .  c o m*/

    public static String date2string(long date) {
        Date theTime = new Date(date);
        return date2string(theTime);
    }

    public static String date2string(Date date, String format) {
        if (date == null) {
            date = new Date();
        }
        if (format == null) {
            format = "yyyy-MM-dd HH:mm:ss";
        }
        SimpleDateFormat sf = new SimpleDateFormat(format);
        return sf.format(date);
    }
}

Related

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