Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Compare Strings using JSTL

843836Aug 3 2004 — edited Aug 3 2004
How can I compare strings with JSTL? One string is a stored date and the other is a generated date. My goal is to set the correct date in a dropdown menu with date values (yyyy-MM-dd) by comparing the current date with the stored.
Code
<%
Calendar cal = Calendar.getInstance(timezone, locale); 
Format fm = new SimpleDateFormat("yyyy-MM-dd");
String date2 = (String) fm.format(cal.getTime()); %>
<c:set var="date1" value="${mb.date}" />   // from database lookup (MySQL Date)

<p><c:out value="${date1}"/>=<%=date2%>:<c:out value="${date1 == '<%=date2%>' }" /></p>
The result is:

2004-08-03 = 2004-08-03 : false


Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 31 2004
Added on Aug 3 2004
3 comments
627 views