Results 1 to 5 of 5
  1. #1
    Samuel is offline Member
    Join Date
    Nov 2010
    Posts
    3
    Rep Power
    0

    Default Check date using jstl

    Please Help,

    I need to do the following:

    I've mixed a bit of code and pseudo code here, hope somebody can fill in the pseudocode for me.

    <c:forEach var="date" in items="${listOfJavaUtilDates}">
    <c:if test="${date} is the same date, but not necessarily time as ${someDate}">
    <td><fmt:formatDate type="date" value="${date}" /></td>
    </c:if>
    </c:forEach>

    <c:if test="if no java.util.Date were in the list which matched ${someDate}">
    <td>No times found</td>
    </c:if>

  2. #2
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,931
    Rep Power
    19

    Default

    A java.util.Date does not have the concept of a date portion, or a time portion. It is simply a long int, representing milliseconds.

    So to compare the date part you would have to either format the Dates into Strings with just the date portion and do an equals() on that, or something involving Calendar. The formaer is probably the easiest for you.

  3. #3
    Samuel is offline Member
    Join Date
    Nov 2010
    Posts
    3
    Rep Power
    0

    Default

    Thanks,

    I would do by storing the output of fmt:formatDate into a var right?

    How about the conditional print if no dates were matched?

  4. #4
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,931
    Rep Power
    19

    Default

    That sounds about right (for the format stuff).

    Presumably there's a test for List size you can do?
    I haven't done this stuff for a couple of years...:)

  5. #5
    Samuel is offline Member
    Join Date
    Nov 2010
    Posts
    3
    Rep Power
    0

    Default

    Ah yes of course.
    <c:if test="${empty listOfJavaUtilDates}" >
    <td>No times found</td>
    </c:if>

    Great, thanks for your help :)

Similar Threads

  1. check the sunday and saturday from a given date range
    By harsha.udupa2008 in forum New To Java
    Replies: 5
    Last Post: 07-20-2010, 08:22 AM
  2. julian date to full date format
    By judy318 in forum New To Java
    Replies: 7
    Last Post: 11-02-2009, 12:17 PM
  3. Compare date input to database with current date
    By hungleon88 in forum Advanced Java
    Replies: 2
    Last Post: 11-25-2008, 08:10 AM
  4. Creating a Gregorian Calendar using a Date object gives date - 1
    By prachi_goliwadekar in forum New To Java
    Replies: 1
    Last Post: 05-08-2008, 08:32 PM
  5. Difference between current date and anothe date
    By vijay balusamy in forum New To Java
    Replies: 1
    Last Post: 04-16-2008, 04:15 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •