oracle 中时间类型 date 与 long 互转
?
在保存时间到数据库时,有时候会保存long型的数据,固定长度是13位,是用当前时间减去1970-01-01,再换算成毫秒得到的结果。
?
oracle中的实现方式:
?
?
----------------------------------------------
1,date转long :
当前时间转成long :
?
select sysdate,?
(sysdate- to_date('1970-01-01','yyyy-mm-dd'))* 24*60*60*1000
current_milli from dual;
?
?
2,long转date
?
select?? to_date('1970-01-01 00:00:00','yyyy-mm-dd hh24:mi:ss')
+?? 1346303500659/1000/24/60/60? from?? dual