This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Date Insert

 
Anonymous
Ranch Hand
Posts: 18944
  • 0
  • send pies
  • Quote
  • Report post to moderator
Hi all,
i want to know how i can convert a string into a date data type.
String date=request.getParameter("txtGraduationdate");
well in my backend i created the field as "date" data type.
So how will i be able to convert this.
Thanks and Regards,
vikram
 
Toyin Sogeke
Greenhorn
Posts: 14
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Sir,
You can use java class java.text.SimpleDateFormat
for your conversion as follows:
String stringDate = "2001-10-08";
SimpleDateFormat sdfInput =
new SimpleDateFormat( "yyyy-MM-dd" );
java.util.Date date = sdfInput.parse( stringDate );
Cheers
Originally posted by vikramnp:
Hi all,
i want to know how i can convert a string into a date data type.
String date=request.getParameter("txtGraduationdate");
well in my backend i created the field as "date" data type.
So how will i be able to convert this.
Thanks and Regards,
vikram

 
Dharmesh Chheda
Ranch Hand
Posts: 204
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello vikramp
the second way is that you can use the StringTokenizer class also
------------------
IBM Certified WebSphere Application Server V3.5 Specialist
 
Jamie Robertson
Ranch Hand
Posts: 1879
MySQL Database Suse
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is the way I convert it. I wish there was an easier way too!

Calendar.getTime() returns a Date object, then use getTime() on the Date object which returns milliseconds, which you can use in a Date constructor to create a new Date.
Jamie


[This message has been edited by Jamie Robertson (edited October 15, 2001).]
[This message has been edited by Jamie Robertson (edited October 15, 2001).]
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic