Since java.sql.Timestamp is inherite from java.util.Date, so simply doing this will do:
SimpleDateFormat ft = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
java.sql.Timestamp ts = new java.sql.Timestamp(System.currentTimeMillis());
System.out.println(ft.format(ts));
Suppose your TIMESTAMP variable is a string, then you could do:
String timeStampStr = "2003-08-23 02:14:38:371";
SimpleDateFormat sdfIn = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:SSS");
SimpleDateFormat sdfOut = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date date = sdfIn.parse(timeStampStr);
String timeStrOut = sdfOut.format(date);
System.out.println(timeStrOut);
920

被折叠的 条评论
为什么被折叠?



