Java tutorial
//package com.java2s; import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.Date; public class Main { public static String dateToString(Date date) { if (date == null) { return null; } try { DateFormat dateformat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); return dateformat.format(date); } catch (Exception e) { return null; } } }