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!

Parsing Date with JSTL

843840Sep 5 2007 — edited Sep 5 2007
Hi Everyone!

I am trying to parse a date in a page, however What I need is the date in "yyyy-MM-dd" and "dd/MM/yyyy" formats. Now
<c:choose>
    <c:when test="${param.from != null}">
        <fmt:parseDate value="${param.from}" var="from"  pattern="dd/MM/yyyy" type="date"></fmt:parseDate>
    </c:when>
    <c:otherwise>
        <jsp:useBean id="from" class="java.util.Date" />
    </c:otherwise>
</c:choose>
<c:choose>
    <c:when test="${param.to != null}">
        <fmt:parseDate value="${param.to}" var="to"  pattern="dd/MM/yyyy" type="date"></fmt:parseDate>
    </c:when>
    <c:otherwise>
        <jsp:useBean id="to" class="java.util.Date" />
    </c:otherwise>
</c:choose>
Solves my problem for the "dd/MM/yyyy" pattern but when I try to use the "yyyy-MM-dd" with parseDate I get exceptions saying e.g "05/09/2005" cannot be parsed I need the "yyyy-MM-dd" pattern for MySQL query.

Any idea/ help will be greatly apperciated.
Thanks
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Oct 3 2007
Added on Sep 5 2007
4 comments
340 views