문제

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?

도움이 되었습니까?

해결책

You can use Joda Time

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

다른 팁

Parse the dates, use Calendar standard class or Joda Time library to compare the dates.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top