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