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

来源:互联网 发布:杭州七克拉淘宝摄影 编辑:程序博客网 时间:2024/06/08 12:32
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 http://xuechenyoyo.iteye.com/blog/373318

0 0
原创粉丝点击