public class Test {
private static final SimpleDateFormat FORMAT = new SimpleDateFormat("yyyy-MM-dd HH:mm:dd");
public static void main(String[] args) throws SQLException {
oracle.sql.TIMESTAMP temp = new oracle.sql.TIMESTAMP();
System.out.println(convertOrclTimestemp2String(temp, null));
}
public static String convertOrclTimestemp2String(oracle.sql.TIMESTAMP temp, String pattern) throws SQLException {
java.sql.Timestamp tt = (java.sql.Timestamp) temp.toJdbc();
if(StringUtils.isNotBlank(pattern)) {
FORMAT.applyPattern(pattern);
}
return FORMAT.format(new Date(tt.getTime()));
}
private static final SimpleDateFormat FORMAT = new SimpleDateFormat("yyyy-MM-dd HH:mm:dd");
public static void main(String[] args) throws SQLException {
oracle.sql.TIMESTAMP temp = new oracle.sql.TIMESTAMP();
System.out.println(convertOrclTimestemp2String(temp, null));
}
public static String convertOrclTimestemp2String(oracle.sql.TIMESTAMP temp, String pattern) throws SQLException {
java.sql.Timestamp tt = (java.sql.Timestamp) temp.toJdbc();
if(StringUtils.isNotBlank(pattern)) {
FORMAT.applyPattern(pattern);
}
return FORMAT.format(new Date(tt.getTime()));
}
}
输出结果:1970-01-01 00:00:01
原文:http://www.cnblogs.com/yfceshi/p/7041160.html
【说明】:本文章由站长整理发布,文章内容不代表本站观点,如文中有侵权行为,请与本站客服联系(QQ:254677821)!