Here you can find the source of getDate(Timestamp ts)
public static String getDate(Timestamp ts)
//package com.java2s; //License from project: Open Source License import java.sql.Timestamp; import java.text.DateFormat; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; public class Main { public static String getDate(Timestamp ts) { if (ts == null) return ""; DateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String tsStr = sdf.format(ts); return tsStr; }/*www.ja va 2 s . c om*/ public static String getDate(Date ts) { if (ts == null) return ""; DateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String tsStr = sdf.format(ts); return tsStr; } public static Date getDate(String dateString) { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); Date date; try { date = sdf.parse(dateString); } catch (ParseException e) { e.printStackTrace(); return null; } return date; } }