File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JDBC 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
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
Marshal

Joined: Mar 22, 2005
Posts: 41863
    
  63
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.


Ping & DNS - my free Android networking tools app
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
Marshal

Joined: Mar 22, 2005
Posts: 41863
    
  63
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
Saloon Keeper

Joined: Oct 23, 2005
Posts: 3704
    
    5

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


My Blog: Down Home Country Coding with Scott Selikoff
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
Marshal

Joined: Mar 22, 2005
Posts: 41863
    
  63
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!
 
jQuery in Action, 2nd edition
 
subject: Parsing the Date!!!