Here you can find the source of dateToStr(Date source)
public static String dateToStr(Date source)
//package com.java2s; //License from project: Open Source License import java.text.SimpleDateFormat; import java.util.Date; public class Main { public static String dateToStr(Date source, String pattern) { String result = null;//from w w w. j a v a 2 s .co m SimpleDateFormat format = new SimpleDateFormat(pattern); result = format.format(source); return result; } public static String dateToStr(Date source) { return dateToStr(source, "yyyy-MM-dd HH:mm:ss"); } }