Unanswered: User to type in Birth Date and Hire Date
I have been trying to write a java code will request the user to type in his or her birth date, and hire Date but have not been able to. Please see what I am only able to do:
*This program will show date as 13/07/1961.
*It is the user that should fill in the date on line?
public class DateDemo
public static void main(String args)
Scanner userInput = new Scanner(System.in);
String date = userInput.nextLine();
Calendar cal = Calendar.getInstance();
cal.set(2005, Calendar.JULY, 13); //year, month, date
Date birthDate = cal.getTime();
SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
String str = sdf.format(birthDate );
System.out.println(" A Special Date: " + str);
I should be very grateful if someone can help me perfect it. I have searched for the solution in all my books but couldn't find any relevant example.