Java tutorial
//package com.java2s; import java.text.SimpleDateFormat; import java.util.Date; public class Main { private static final String DEFAULT_DATE_PATTERN = "yyyy-MM-dd"; public static String formatDate(Date date, String pattern) { SimpleDateFormat format = new SimpleDateFormat(pattern); return format.format(date); } public static String formatDate(Date date) { return formatDate(date, DEFAULT_DATE_PATTERN); } }