This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
The moose likes JDBC and Relational Databases and the fly likes Parsing the Date!!! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "Parsing the Date!!!" Watch "Parsing the Date!!!" New topic
Author

Parsing the Date!!!

Rajkumar balakrishnan
Ranch Hand

Joined: May 29, 2008
Posts: 445

I use the below code to get the date from vend.jsp and parse the date to uts default format and check the DB for any entries.. The problem is it returns an error that tell me that
java.text.ParseException: Unparseable date "17/07/2008"
What is the problem... Please help me resolve this issue...


Never try to be a hard-worker. Be a smart-worker.
My Blog
Ulf Dittmer
Rancher

Joined: Mar 22, 2005
Posts: 42958
    
  73
You can make it much easier on yourself by using PreparedStatement and its setDate method. That will perform all necessary date conversions.

I also suspect that you fundamentally misunderstand how date formatting works. If you append a Date object to a String, you will cause its toString method to be called for creating a String representation of the Date - which will most likely not be the format you're looking for.
Rajkumar balakrishnan
Ranch Hand

Joined: May 29, 2008
Posts: 445

Originally posted by Ulf Dittmer:
You can make it much easier on yourself by using PreparedStatement and its setDate method. That will perform all necessary date conversions.

I also suspect that you fundamentally misunderstand how date formatting works. If you append a Date object to a String, you will cause its toString method to be called for creating a String representation of the Date - which will most likely not be the format you're looking for.

Ulf Dittmer
Rancher

Joined: Mar 22, 2005
Posts: 42958
    
  73
Are you sure that there are dates that match the query, down to the exact same hour, second and millisecond?
Rajkumar balakrishnan
Ranch Hand

Joined: May 29, 2008
Posts: 445

Thanks Ulf,
I take a look at how to parse the date and do some required thing... which will reward me by getting out of the problem and my program works...I must do some homework regarding DATE.. Because i post more queries regarding that...
Scott Selikoff
author
Saloon Keeper

Joined: Oct 23, 2005
Posts: 3740
    
  10

For the millionth time people... never put JDBC code inside a JSP!


[OCA 8 Book] [Blog]
Rajkumar balakrishnan
Ranch Hand

Joined: May 29, 2008
Posts: 445

Originally posted by Scott Selikoff:
For the millionth time people... never put JDBC code inside a JSP!


Then please tell me how could i pass the resultset from Servlet File to JSP?
Ulf Dittmer
Rancher

Joined: Mar 22, 2005
Posts: 42958
    
  73
As a request attribute, after you've stored the contents of the ResultSet in one or more suitable collection objects. Then you can use JSTL to iterate over them in the JSP.
Rajkumar balakrishnan
Ranch Hand

Joined: May 29, 2008
Posts: 445

I'll try that and post here if i find any difficulties!
 
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com
 
subject: Parsing the Date!!!
 
It's not a secret anymore!