Im writing a program that needs to be able to find the difference between two dates using java.util.date format. I’m using the SimpleDateFormat class to parse the string input but it seems to be parsing wrong. Here is my code. I appreciate any help
SimpleDateFormat s = new SimpleDateFormat("yyyy/mm/dd");
Date startDate = s.parse(dateField.getText()); //input is 2012/03/10
System.out.println(START_DATE);//output is Tue Jan 10 00:03:00 MST 2012
You must use
yyyy/MM/ddinstead ofyyyy/mm/dd. Becausemmis for minutes andMMis for month