Java Date to String dateToString(Date d)

Here you can find the source of dateToString(Date d)

Description

date To String

License

Open Source License

Declaration

public static String dateToString(Date d) 

Method Source Code


//package com.java2s;

import java.text.DateFormat;

import java.text.SimpleDateFormat;

import java.util.Date;
import java.util.Locale;

public class Main {
    public static final String DATE_FORMAT = "yyyy/MM/dd";

    public static String dateToString(Date d) {
        SimpleDateFormat sd = new SimpleDateFormat(DATE_FORMAT);
        String date = sd.format(d);
        return date;
    }//from  w ww.j  a  v  a 2s.c o  m

    public static String format(Date d, String format) {
        return format(d, format, Locale.getDefault());
    }

    public static String format(Date d, String format, Locale locale) {
        if (d == null)
            return "";
        DateFormat df = new SimpleDateFormat(format, locale);
        return df.format(d);
    }
}

Related

  1. dateToStr(Date source)
  2. datetoStr2(Date date)
  3. datetoStr3(Date date)
  4. dateToStrIBInput(Date date)
  5. dateToString(Date d)
  6. dateToString(Date d)
  7. dateToString(Date d)
  8. dateToString(Date data, String format)
  9. dateToString(Date date)