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

如何将oracle.sql.TIMESTAMP 转换为 java date

2014-02-16 16:28 495 查看
private String getDate(Object value) {

Timestamp timestamp = null;
try {
timestamp = (Timestamp) value;
} catch (Exception e) {
timestamp = getOracleTimestamp(value);
}
if(timestamp!=null)
return (new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.S"))     .format(timestamp);
else return null;
}
/**
* @reference oracle.sql.Datum.timestampValue();
* @return
*/
private Timestamp getOracleTimestamp(Object value) {
try {
Class clz = value.getClass();
Method m = clz.getMethod("timestampValue", null);
//m = clz.getMethod("timeValue", null); 时间类型
//m = clz.getMethod("dateValue", null); 日期类型
return (Timestamp) m.invoke(value, null);

} catch (Exception e) {
return null;
}
}


from /article/3988235.html
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐