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
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
Ads