您的位置:首页 > 数据库 > Oracle

Oracle TIMESTAMP的处理

2017-06-17 19:48 120 查看
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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: