在pl / sql中,
select to_date('2012-01-01T12:01:01', 'yyyy-mm-dd"T"hh24:mi:ss') from dual;
作品。
但是在java中使用时,
String sql = "select to_date('2012-01-01T12:01:01', 'yyyy-mm-dd\"T\"hh24:mi:ss') from dual";
不起作用。
请帮我一把。
错误:
com.google.gson.JsonSyntaxException: java.lang.NumberFormatException: For input string: "2014-10-31T13:16:38"
at com.google.gson.internal.bind.TypeAdapters$8.read(TypeAdapters.java:263)
at com.google.gson.internal.bind.TypeAdapters$8.read(TypeAdapters.java:253)
...
at com.google.gson.Gson.fromJson(Gson.java:805)
at com.google.gson.Gson.fromJson(Gson.java:770)
at com.google.gson.Gson.fromJson(Gson.java:719)
at dao.UserManagerNB.getData(UserManagerNB.java:64)
at dao.UserManagerNB.editApplianceApplication(UserManagerNB.java:92)
at com.svse.servlet.PutAppJsonServlet.doGet(PutAppJsonServlet.java:80)
...
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.NumberFormatException: For input string: "2014-10-31T13:16:38"
at sun.misc.FloatingDecimal.readJavaFormatString(Unknown Source)
at java.lang.Double.parseDouble(Unknown Source)
at com.google.gson.stream.JsonReader.nextLong(JsonReader.java:975)
at com.google.gson.internal.bind.TypeAdapters$8.read(TypeAdapters.java:261)
... 30 more
出了什么问题?
答案 0 :(得分:0)
所以你的代码应该是:
String sql = "select to_date('2012-01-01T12:01:01', 'yyyy-mm-dd\"T\"hh24:mi:ss') from dual";