|
|
Click Here To Get Amazing Facebook Profile Covers,Status Messages
How to compare two dates in jsp
If you want to perform some sort of date comparison in jsp then you need java.util.Date class methods.The two dates in jsp can not be compared using logical operators(<,>,=).
The simplest one is to use compareTo method of java.util.Date class in order to compare two date objects in jsp.
Depending on date values compareTo() returns 3 different numeric value.
date1.compareTo(date2)
It returns 0 if dates are equal
It returns 1, if first date is greater than second date
It returns -1, if first date is less than second date
As an alternate option you can use after,before or equals methods of Date class.
date1.after(date2)
returns a Boolean value TRUE if Date1 is greater than date2
date1.before(date2)
returns a Boolean value TRUE if Date1 is less than date2
date1.equals(date2)
returns a Boolean value TRUE if Date1 is equal to date2
- rajesh's blog
- Login or register to post comments
-
Similar entries
- How to compare strings in JAVA
- The operator < is undefined for the argument type(s) java.util.Date, java.util.Date
- The type Date is ambiguous jsp error
- How to add or subtract days in a date using JSP
- conversion of date to DD-MMM-YYYY format in asp.net
- Uttar Pradesh Class 12th Intermediate Exam Time Table 2012
- ASP code for adding days in date
- Rajasthan Public Service Commision Revised Exam Schedule IInd Grade Teacher Recruitment 2011
- How to hide post date and time in blogger
- How to format datetime in SQL query