public static String returnDate(String s){ try{ Timestamp ts = Timestamp.valueOf(s); Calendar c = Calendar.getInstance(); c.setTime(ts); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); //System.out.println(sdf.format(c.getTime())); return sdf.format(c.getTime()); }catch (Exception e) { e.printStackTrace(); } return ""; }
写个main方法try一把!