JDBC查询ORACLE TIMESTAP WITH TIME ZONE 查询结果相差8-11小时

一、问题原因

https://blog.csdn.net/qq_41705555/article/details/109078669

 

 

 

 

二、解决办法

https://blog.csdn.net/SAN_YUN/article/details/84925383?utm_medium=distribute.pc_aggpage_search_result.none-task-blog-2~all~sobaiduend~default-2-84925383.nonecase&utm_term=%E7%BB%99date%E8%AE%BE%E7%BD%AE%E6%97%B6%E5%8C%BA&spm=1000.2123.3001.4430

tring timeStr = "2017-8-24 11:17:10"; // 字面时间
SimpleDateFormat bjSdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
bjSdf.setTimeZone(TimeZone.getTimeZone("Asia/Shanghai"));
Date bjDate = bjSdf.parse(timeStr);  // 解析
System.out.println("字面时间: " + timeStr +",按北京时间来解释:" + bjSdf.format(bjDate) + ", " + bjDate.getTime());
 
SimpleDateFormat tokyoSdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");  // 东京
tokyoSdf.setTimeZone(TimeZone.getTimeZone("Asia/Tokyo"));  // 设置东京时区
Date tokyoDate = tokyoSdf.parse(timeStr); // 解析
System.out.println("字面时间: " + timeStr +",按东京时间来解释:"  + tokyoSdf.format(tokyoDate) + ", " + tokyoDate.getTime())

  

------------------ 微信支付扫码赞赏我--------------

        
posted @ 2020-11-13 16:52  迷神图卷  阅读(299)  评论(0编辑  收藏  举报