0

I'm using two JFormattedTextFields in Java for Date in my JFrame. I formatted them in format (DD/MM/YYYY).

How can i find difference between them in days?

4

2 回答 2

2

您可以使用乔达时间

DateTime date1 = new DateTime(2013, 12, 20, 0, 0);
DateTime date2 = new DateTime(2013, 12, 23, 0, 0);
Days.daysBetween(date1, date2).getDays(); // Will return 3 
//since date2 is 3 days after date1
于 2013-10-20T13:49:46.683 回答
0

解析日期,使用 Calendar 标准类或 Joda Time 库来比较日期。

于 2013-10-20T13:36:58.837 回答