Java tutorial
//package com.java2s; import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.Date; public class Main { public static String formatDate(Date paramDate) { return format(paramDate, DateFormat.getDateInstance()); } public static String format(Date paramDate, String paramString) { return format(paramDate, new SimpleDateFormat(paramString)); } public static String format(Date paramDate, DateFormat paramDateFormat) { if (paramDate != null) return paramDateFormat.format(paramDate); return null; } }