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

Declaration

public static String dateToString(Date date, String format) 

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 final String DF_YMD = "yyyy-MM-dd";

    public static String dateToString(Date date, String format) {
        if (date == null) {
            return "";
        }//  www  . j a v  a  2 s .  co  m
        synchronized (date) {
            SimpleDateFormat df = new SimpleDateFormat(format);
            return df.format(date);
        }
    }

    public static String dateToString(Date date) {
        return dateToString(date, DF_YMD);
    }
}

Related

  1. dateToString(Date date, String format)
  2. dateToString(Date date, String format)
  3. dateToString(Date date, String format)
  4. dateToString(Date date, String format)
  5. dateToString(Date date, String format)
  6. dateToString(Date date, String formatStr)
  7. DateToString(Date date, String parttern)
  8. DateToString(Date date, String pattern)
  9. dateToString(Date date, String pattern)