我有兩個字符串格式的日期。我需要在幾天內得到這兩個日期之間的差異。我如何得到它?我對這些日期format.please新非常新我有任何建議。以字符串格式計算兩個日期之間的日期差異
2017-06-13
2017-06-27
String newDate = null;
Date dtDob = new Date(GoalSelectionToDate);
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
newDate = sdf.format(dtDob);
String newDate1 = null;
SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd");
newDate1 = sdf1.format(currentDate);
System.out.println("currentdateformat"+newDate1);
System.out.println("anotherdateformat"+newDate);
這是否有幫助 - https://stackoverflow.com/questions/13732577/convert-string-to-date-to-calculate-the-difference –
可能的重複[轉換字符串到日期以計算差異](https: //sackoverflow.com/questions/13732577/convert-string-to-date-to-calculate-the-difference) – Tom