refactor the code in Controller.java and add a check for valid date inpu...

refactor the code in Controller.java and add a check for valid date inpu...