Json对Postgresql日期时间转换的响应Java Postgresql [英] Json response to postgresql datetime conversion Java postgresql
问题描述
我正在获取日期时间字段的JSON响应,如下所示:
/Date(1534291200000)/
和PT12H18M02S
I am getting the JSON responses for the Date time field as follows:
/Date(1534291200000)/
and PT12H18M02S
SELECT CAST('ClearingDate' AS TIMESTAMP) from testdata;
在使用CAST函数或to_timestamp
时,出现以下错误:
On using CAST functions or to_timestamp
I am getting the following error:
错误:类型为timestamp的无效输入语法:"/Date(1534291200000)/" SQL状态:22007
ERROR: invalid input syntax for type timestamp: "/Date(1534291200000)/" SQL state: 22007
如何使用Postgresql将其转换为时间戳?如果不是,postgresql是否可以用Java做到这一点?
How can I convert this to timestamp using postgresql? If not postgresql is there a way to do so in Java?
推荐答案
直接在PostgreSQL中进行转换的解决方案:
The solution to directly convert it in PostgreSQL:
to_timestamp(CAST(SUBSTRING (CAST(Clearingdate AS varchar), 9, 10) AS NUMERIC))
from date_test;
我终于明白了.非常感谢您的所有投入.
I finally figured it out. Thanks a lot for all your inputs.
这篇关于Json对Postgresql日期时间转换的响应Java Postgresql的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!