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?
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.