Here you can find the source of parseToString(Date date, String format)
public static String parseToString(Date date, String format)
//package com.java2s; //License from project: Open Source License import java.text.SimpleDateFormat; import java.util.Date; public class Main { public static String parseToString(Date date, String format) { if (date == null) { return ""; }/*from ww w .ja v a2 s. com*/ if (format != null) { return (new SimpleDateFormat(format)).format(date); } else { return (new SimpleDateFormat("yyyy-MM-dd HH:mm:ss")).format(date); } } }