wood burning stoves 2.0*
The moose likes Servlets and the fly likes java.util.Date as parameter in servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "java.util.Date as parameter in servlet" Watch "java.util.Date as parameter in servlet" New topic

java.util.Date as parameter in servlet

Brian Snyder
Ranch Hand

Joined: Feb 03, 2001
Posts: 142
I know that request.getParameter("xxx") returns a string. Is there any way to get it to return a java.util.Date???
I would like to get the date from my applet and write it to a database in date format. Maybe I should just write it as a String???
What do you think??? See code from applet to servlet below.
Many thanks!!!

code from servlet.....
Bosun Bello
Ranch Hand

Joined: Nov 06, 2000
Posts: 1510
No. It always returns a string. You just have to try to convert the returned string to a date. There are some methods in the java.text package that you can use.


So much trouble in the world -- Bob Marley
Brian Snyder
Ranch Hand

Joined: Feb 03, 2001
Posts: 142
Thanks for your help Bosun.
My logic was off. I can get the current time within the servlet itself by using the following code:
utilDate = new java.util.Date();
long dd = utilDate.getTime();
sqlDate = new java.sql.Date(dd);

I figured it out right after I posted this question.
I agree. Here's the link: http://aspose.com/file-tools
subject: java.util.Date as parameter in servlet
Similar Threads
preparedStatement.setDate and java.util.Date
util.Date to sql.Date
Problem Reading/Writing Date
Java mail using gmail
Save date to the database