Java Date to String dateToString1(Date date, String formatIn)

Here you can find the source of dateToString1(Date date, String formatIn)

Description

date To String

License

Open Source License

Declaration

public static String dateToString1(Date date, String formatIn) 

Method Source Code

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

import java.util.Date;

public class Main {
    /**//  w  w w .j  av a  2s  .c o m
     * @param yyyy:MM:dd
     *            HH:mm:ss
     * @return
     */
    public static final String patternD = "yyyy-MM-dd HH:mm:ss";

    public static String dateToString1(Date date, String formatIn) {
        String format = formatIn;
        if (date == null) {
            return "";
        }
        if (format == null) {
            format = patternD;
        }
        java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat(format);
        return sdf.format(date);
    }
}

Related

  1. dateToString(final Date date)
  2. dateToString(final Date value, final boolean utc)
  3. dateToString(java.util.Date currdate, String strFormat)
  4. dateToString(String date, String format)
  5. dateToString(String str, DateTimeFormatter dateTimeFormatter)
  6. dateToString_yyyyMMddHHmmssSSS(Date date)
  7. DateToStringByformat2(Date date)
  8. dateToStringFecha(Date fecha)
  9. dateToStringFormat(Date dt, String format)