javadategwtdatebox

How to calculate difference in days between two dateboxes in GWT?


I have 1 datebox (datebox1) in my GWT application, which allows users to set the date in past.

Datebox1 is set to following format (not that it probably matters): datebox1.setFormat(new DateBox.DefaultFormat (DateTimeFormat.getFormat("EEE, MMM dd, yyyy")));

How do I programatically calculate the difference in days between the date selected in the date box and the current date.

I can't find much on the net and would appreciate a simple example.


Solution

  • The simplest way:

    Date currentDate = new Date();
    int daysBetween = CalendarUtil.getDaysBetween(myDatePicker.getValue(), currentDate);