Java tutorial
//package com.java2s; import java.sql.Timestamp; import java.text.SimpleDateFormat; import java.util.Date; public class Main { private static final SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); /** * * @param object * @return */ protected static Float toFloat(Object object) { String str = toString(object); if ("".equals(str)) return 0.0f; else return Float.parseFloat(str); } /** * * @param object * @return */ protected static String toString(Object object) { if (object == null) { return ""; } else if (object instanceof Date) { return df.format(object); } else if (object instanceof Timestamp) { System.out.println("------" + df.format(object)); return df.format(object); } else return object.toString(); } }