Vivek Dhiman Vivek Dhiman - 1 year ago 92
Java Question

Time difference between two calander dates

I am looking for to calculate the time difference between two calendar dates and need the result difference in minutes. Below is what I am trying but it says: can't apply - operator. My

gives me Calendar object. Any idea how can I achieve this.

long lastModified = page.getLastModified().getTime() - Calendar.getInstance().getTime()


Answer Source

getTime() returns Date instance and there is no overloaded - operator for Date. You may try with getTimeInMillis() to get difference milliseconds between two dates. You can later convert these milliseconds to minutes for instance with

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download