Here you can find the source of date2str(java.util.Date date)
public static String date2str(java.util.Date date)
//package com.java2s; //License from project: Apache License import java.text.SimpleDateFormat; public class Main { static public SimpleDateFormat MMddYYYY_HHmmss = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); static public SimpleDateFormat yyyyMMdd = new SimpleDateFormat("yyyy-MM-dd"); public static String date2str(java.util.Date date) { if (date == null) return ""; try {//from w ww.j a v a2 s .co m return MMddYYYY_HHmmss.format(date); } catch (Exception e) { return ""; } } static public String date2str(java.sql.Date date) { if (date == null) return ""; try { return yyyyMMdd.format(date); } catch (Exception e) { return ""; } } }