Oracle TIMESTAMP的处理

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()));
}

}


输出结果:1970-01-01 00:00:01

posted @ 2017-06-17 19:48  yfceshi  阅读(732)  评论(0编辑  收藏  举报