Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Java-Beginners How to Convert String to Date?
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


Java Coder
How to Convert String to Date?
1 Answer(s)      10 months ago
Posted in : Java Beginners


Hi,

I am new in Java and learning the Date manipulation in Java. I have to write a program in Java which converts the String into Date object. My user enters the date into input field and now I have to convert it to Date object.

Tell me How to Convert String to Date?

Thanks


Advertisement
View Answers

January 4, 2014 at 10:24 PM


Hi Dude,

Its very easy to convert the String into date format. There is a class SimpleDateFormat which already available in the JDK which you can use for converting the String representation of date into real Date object.

You can use the following code:

  formatter = new SimpleDateFormat("dd-MMM-yy");
  date = (Date)formatter.parse(str_date);

The parse() method of the SimpleDateFormat class returns the date object.

Read more at Convert String to Date.

Thanks



Related Tutorials/Questions & Answers:
Advertisements
Advertisements
 

 

 

DMCA.com