Here you can find the source of dateToString1(Date date, String formatIn)
public static String dateToString1(Date date, String formatIn)
//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); } }