原文:http://www.cnblogs.com/lambertwe/p/6116402.html
今天在項目中查詢流程相關信息中,發現了其中的日期字段存的信息很奇怪,是一串數值,后面發現是long類型或者integer類型數值,然后就需要轉行成相應的日期格式了。
在網上搜索一番得到解決:
1、date轉long:
select sysdate, (sysdate-to_date('1970-01-01 08:00:00','yyyy-mm-dd hh24:mi:ss'))* 24*60*60*1000 current_milli from dual;
2、long轉date:
select to_date('1970-01-01 08:00:00','yyyy-mm-dd hh24:mi:ss') + 1241450728000/1000/24/60/60 from dual
其中為什么是 1970-01-01 08:00:00 而不是 1970-01-01 00:00:00是因為我們是東八區呀。