0 votes
in JAVA by

How to convert string to date in java in yyyy-mm-dd format?

1 Answer

0 votes
by

How to convert string to date in java in yyyy-mm-dd format?

String start_dt = ""2011-01-01"";

DateFormat formatter = new SimpleDateFormat(""yyyy-MM-DD""); 

Date date = (Date)formatter.parse(start_dt);

SimpleDateFormat newFormat = new SimpleDateFormat(""MM-dd-yyyy"");

String finalString = newFormat.format(date);

🔗Reference: stackoverflow.com

🔗Source: Java Interview Questions and Answers

...