Talib
Talib

Reputation: 1164

Compare calendar dates in JSP

I have to check if the date I am getting has passed 24 hours or not, I have tried many things but failed.

My date from the database looks like this:

2017-06-14 13:18:01.0000000

It's a Calendar object. And I have to check if this date has passed 24 hours in if statement.

How to add hours in time so I can add 24 hours and compare it with the current time?

Upvotes: 1

Views: 281

Answers (1)

Alex
Alex

Reputation: 11579

It is better to check dates in backend.

public boolean isDateValid() {
...
}

and in JSTL

<c:if test="${yourModel.dateValid}">
...
</c:if>

Upvotes: 2

Related Questions