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