Here you can find the source of formatStr(Date date)
public static String formatStr(Date date)
//package com.java2s; //License from project: Open Source License import java.text.SimpleDateFormat; import java.util.Date; public class Main { public final static String DEFAULT_YMD_FORMAT = "yyyy-MM-dd"; public static String formatStr(Date date) { SimpleDateFormat sdf = new SimpleDateFormat(DEFAULT_YMD_FORMAT); if (date == null) { return ""; }//from w ww .j a va2 s . co m return sdf.format(date); } }