Here you can find the source of dateTimeToString(Date date)
public static String dateTimeToString(Date date)
//package com.java2s; //License from project: Apache License import java.text.SimpleDateFormat; import java.util.Date; public class Main { private static SimpleDateFormat formatter = new SimpleDateFormat( "yyyy-MM-dd HH:mm:ss"); public static String dateTimeToString(Date date) { if (date != null) { return (formatter.format(date)); } else// w w w . java 2 s . c o m return ""; } }