• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Date Insert

 
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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


 
Ranch Hand
Posts: 204
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 1879
MySQL Database Suse
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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).]
 
reply
    Bookmark Topic Watch Topic
  • New Topic