Here you can find the source of formatDateYMD(Object date)
public static String formatDateYMD(Object date)
//package com.java2s; //License from project: Apache License import java.text.SimpleDateFormat; import java.util.Date; public class Main { public static String formatDateYMD(Object date) { return formatDate(date, "yyyy-MM-dd"); }/* ww w . j ava 2s . c o m*/ public static String formatDate(Object date, String fmt) { if (date == null) { return null; } if (!(date instanceof Date)) { return date.toString(); } SimpleDateFormat sdf = new SimpleDateFormat(fmt); return sdf.format(date); } }