Here you can find the source of dateToStr(Date date)
public static String dateToStr(Date date)
//package com.java2s; //License from project: Apache License import java.text.SimpleDateFormat; import java.util.Date; public class Main { public static String dateToStr(Date date) { String s = ""; if (date == null) { return ""; }// w w w . ja v a 2 s . c o m SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); try { s = sdf.format(date); } catch (Exception e) { } return s; } }