Reputation: 872
How to use the value of "ft" in c:if condition.
<% Date dNow = new Date( );
SimpleDateFormat ft =
new SimpleDateFormat ("yyyy.MM.dd hh:mm:ss a zzz");
out.print( "<h2 align=\"center\">" + ft.format(dNow) + "</h2>");%>
Here is my way of using code in JSP(sample code)
<c:if test="${row.RecvDate}-$(ft) > 48"></c:if> .....
Explanation of my task: Need to subtract two date and check the condition is greater the 48 hours, the row should be highlight in green color, otherwise fine (no change).
So I got values from database and doing validation in JSP page for highlighting row as per condition.
Upvotes: 1
Views: 681
Reputation: 985
convert your date in to integer and subtact it and compare it as you wish
int i = (int) (new Date().getTime());
System.out.println("Integer : " + i);
System.out.println("Long : "+ new Date().getTime());
System.out.println("Long date : " + new Date(new Date().getTime()));
Integer : 1345619256
Long : 1345619256308
Long date : Wed Aug 22 16:37:36 CST 2012
Upvotes: 1