• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

parsing in servlet  RSS feed

 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This isn't a servlet specific issue. You need to look at the "DateFormat" class, and its methods for converting between Strings and Dates.
 
Author and all-around good cowpoke
Rancher
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Bill
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!