I'm trying to make my user input a date in "words" form, then print it as a date.
For example:
System.out.print("Enter Date: ")
String inDate = nextLine()
User will input January 21, 2019
, then I will print it as 01/21/2019
.
I'm trying to make my user input a date in "words" form, then print it as a date.
For example:
System.out.print("Enter Date: ")
String inDate = nextLine()
User will input January 21, 2019
, then I will print it as 01/21/2019
.
SimpleDateFormat fmt = new SimpleDateFormat("MMM dd, yyyy");
SimpleDateFormat fmtOut = null;
Date date = null;
try {
date = fmt.parse("January 21, 2019");
fmtOut = new SimpleDateFormat("MM/dd/yyyy");
System.out.println(fmtOut.format(date))
} catch (ParseException e) {
e.printStackTrace();
}