The screen formate should be:
"dd-MM-yyyy HH:mm"
So far is have
try
{
boolean correct = false;
while(!correct)
{
Scanner in = new Scanner(System.in);
System.out.print("Date: ");
String ans = in.next();
if(ans.matches("dd-MM-yyyy HH:mm"))
{
correct = true;
date = ans;
}
else{
System.out.println("Please use this format (dd-MM-yyyy HH:mm)");
}
}
}catch (InputMismatchException e)
{
System.out.println("--Please Enter an String--");
}
What is the best way validate(check) the user has typed it in like this?