Vivek Dhiman Vivek Dhiman - 7 months ago 25
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()



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