How can I find the number of days between two Dates?
问题 I have two Date s. How can I tell the difference between these two dates in days? I have heard of SimpleDateFormat , but I don't know how to use it. I tried this: String fromdate = "Apr 10 2011"; SimpleDateFormat sdf; sdf = new SimpleDateFormat("MMM DD YYYY"); sdf.parse(fromdate); Calendar cal = Calendar.getInstance(); cal.setTime(sdf); I also tried this: String date1 = "APR 11 2011"; String date2 = "JUN 02 2011"; String format = "MMM DD YYYY"; SimpleDateFormat sdf = new SimpleDateFormat