Java Date to String dateToStringFormat(Date dt, String format)

Here you can find the source of dateToStringFormat(Date dt, String format)

Description

date To String Format

License

Open Source License

Parameter

Parameter Description
dt a parameter
format yyyy.MM.dd

Exception

Parameter Description
ParseException an exception

Return

str yyyy.MM.dd");

Declaration

public static String dateToStringFormat(Date dt, 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 {
    /**/*from w w  w .  j  a  v  a  2s.  co m*/
     * 
     * @param dt 
     * @param format yyyy.MM.dd
     * @return str yyyy.MM.dd");
     * @throws ParseException 
     */
    public static String dateToStringFormat(Date dt, String format) {
        SimpleDateFormat fmt = new SimpleDateFormat(format);
        String dtStr = "";
        if (dt != null) {
            dtStr = fmt.format(dt).toString();
        }
        return dtStr;
    }
}

Related

  1. dateToString(String str, DateTimeFormatter dateTimeFormatter)
  2. dateToString1(Date date, String formatIn)
  3. dateToString_yyyyMMddHHmmssSSS(Date date)
  4. DateToStringByformat2(Date date)
  5. dateToStringFecha(Date fecha)
  6. dateToStringShort(Date date)
  7. dateToStringTemporalCoverage(Date date)
  8. dateToStringVerbose(Date date)
  9. dateToStringWithFormat(Date dateToString, String dateFormat)