How to convert string to date format in java?

2.59K 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.

 

Changed status to publish
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;
}

 

Changed status to publish
Add a Comment
Write your answer.