How to convert string to date format in java?

4.23K viewsJava
0

How to convert string to date format in java?

Best way to convert a string to date format using java, please give me suggestions.

 

Mounika Changed status to publish November 30, 2020
Add a Comment
0

Below find the piece of code for converting the string to date format :

public Date convertStrToDate(String date, String dateFormat) {
		DateFormat formatter;
		Date convertDate;
		formatter = new SimpleDateFormat(dateFormat);
		convertDate = (Date) formatter.parse(date);
		return convertDate;
}

 

Manohar Changed status to publish June 17, 2019
Add a Comment
Write your answer.