Here you can find the source of formatDate(Date date)
public static String formatDate(Date date)
//package com.java2s; //License from project: Open Source License import java.text.SimpleDateFormat; import java.util.Date; public class Main { public static String formatDate(Date date) { String dateString = date.toString(); SimpleDateFormat formatter = new SimpleDateFormat("dd-MM-yyyy"); try {//from ww w . ja v a2s .com dateString = formatter.format(date); } catch (IllegalArgumentException iae) { iae.printStackTrace(); } return dateString; } }