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

Related questions

0 votes
asked Oct 20, 2020 in JAVA by sharadyadav1986
0 votes
asked Oct 18, 2020 in JAVA by sharadyadav1986
...