Here you can find the source of formatToString(Date date)
public static String formatToString(Date date)
//package com.java2s; //License from project: Open Source License import java.text.SimpleDateFormat; import java.util.Date; public class Main { public static final String FROMAT = "yyyy-MM-dd HH:mm:ss"; public static String formatToString(Date date) { String time = null;//w w w .j a va 2 s .c o m SimpleDateFormat format = new SimpleDateFormat(FROMAT); time = format.format(date); return time; } }