• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Getting an error while fetching Date time from DB in Java

 
Gershwin Yesudhas
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ranchers,

I'm trying to fetch a column from DB in my java code but getting the below error.

org.springframework.web.util.NestedServletException: Request processing failed; nested exception is java.lang.Exception
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:583)
org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:501)
javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)

root cause

java.lang.Exception
com.avon.gi.repsuite.ctrl.OnlineOrderDetailsController.handleRequest(OnlineOrderDetailsController.java:552)
org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.handle(SimpleControllerHandlerAdapter.java:48)
org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:875)
org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:809)
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:571)
org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:501)
javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)



The column name is ORD_MGMT_IP_DT and it is of Date format for example in my case it is 3/12/2010 9:27:11 PM in the db.
I need to fetch the date time and the AM/PM in the format dd/MM/yyyy hh:mm:ss a
I tried fetching it by writing it as to_char(rep_ord_trkg.ord_mgmt_ip_dt,'dd/MM/yyyy hh:mm:ss a') AS OrderDate in Java.


But am not getting the values on the page instead, I'm getting an Error 500 on page. When i tried without the 'a' i.e for the AM/PM i got the value in the page but the time was incorrect, like 12/3/2010 9:03:11. I'm quite confused that, how this is failing to fetch me the correct values when given with 'a' and it is throwing exceptions when given with 'a'.

Kindly help me out on this ranchers. Thanks a ton in advance.Awaiting your replies.
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Which database are you using ?
 
Gershwin Yesudhas
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm using Oracle 10G.
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your format is not correct. Try 'DD/MM/YYYY HH:MI:SS PM' instead.
 
Gershwin Yesudhas
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot Christophe. It worked. Thanks again Rancher.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic