Convert a String to Date

This code example shows how to format a String to a Date object. The method convertStringToDate actually takes three arguments as integers, date, month and year, and then concatenates these values to a String date.
The String date is them passed to the parse method of the SimpleDateFormat object that returns a java.util.Date object. The SimpleDateFormat class takes a String format as input to the constructor.
In case the format fails a ParseException is thrown.

The output from the code above looks like:

Search for more Java info on this site here:
Custom Search

Please type any questions here.