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 Servlets and the fly likes parsing in servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

JavaRanch » Java Forums » Java » Servlets
Bookmark "parsing in servlet" Watch "parsing in servlet" New topic

parsing in servlet

sachin cknd

Joined: Feb 10, 2001
Posts: 12
i am accepting string from html page to my servlet using dopost method.
but this is the date my user is entering from the page.
i want to insert this date into my database(ms access)where i have defined a field of data type "date/time".
the program throws sql exception regarding the mis match of data type.
because i have "date/time " in the table and string in the servlet.
is their any way by which i can parse the string in to date??
thanks in advance
Margaret Carver

Joined: Feb 10, 2001
Posts: 4
This isn't a servlet specific issue. You need to look at the "DateFormat" class, and its methods for converting between Strings and Dates.
William Brogden
Author and all-around good cowpoke

Joined: Mar 22, 2000
Posts: 13001
Good practice requires that you verify that you have a reasonable date in your user's input. Since in order to do that you will have to parse the submission, you will have all the parts to create a date in the format the database wants.
Exactly how you do the parsing depends on the format your form asks for. Look at the java.util.Calendar class
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link:
subject: parsing in servlet
It's not a secret anymore!