Here you can find the source of formatDate(long date)
public static String formatDate(long date)
//package com.java2s; //License from project: Apache License import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; public class Main { public static String formatDate(Date date, String format) { SimpleDateFormat formatter = new SimpleDateFormat(format); System.out.println(formatter.format(date).toString()); return formatter.format(date).toString(); }/*from w w w. ja v a 2s .c o m*/ public static String formatDate(String date, String format) { SimpleDateFormat sdf = new SimpleDateFormat(format); SimpleDateFormat sdf2 = new SimpleDateFormat(format); String sss = null; try { sss = sdf2.format(sdf.parse(date)); //System.out.println(sss); } catch (ParseException e) { // TODO Auto-generated catch block e.printStackTrace(); } return sss; } public static String formatDate(long date) { SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd"); System.out.println(formatter.format(date)); return formatter.format(date); } }