Here you can find the source of ToDate(Object o)
public static final Date ToDate(Object o)
//package com.java2s; //License from project: Apache License import java.text.SimpleDateFormat; import java.util.Date; public class Main { public static final Date ToDate(Object o) { return ToDate(ToString(o)); }//ww w .j ava 2 s .c om public static final Date ToDate(String s) { if (s.isEmpty()) return null; Date dt; try { final SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss"); dt = dateFormat.parse(s); } catch (Exception e) { dt = null; } return dt; } public static final String ToString(Object o) { return o != null ? o.toString() : ""; } public static final String ToString(String s) { return s != null ? s : ""; } }