Results 1 to 3 of 3
  1. #1
    gioarvan is offline Member
    Join Date
    Apr 2011
    Posts
    3
    Rep Power
    0

    Question Compare Mysql date with current date

    Hello,

    I am implementing an application for online auctions, it is part of my essay @ the university.

    I am using JSP/EL as basic tools. I want to compare the date that comes from mysql items table (start_date : the day that the auction starts) with the current date to check if the auction is started.

    How to do that with JSP/EL ?

    i can retrieve the data form mysql using JSTL sql tag and then pass it to a parameter e.g c:set var="start_date". But the problem is that this is a type of string and the current date is a type of java.util.date. How to convert them? in order to use EL to compare them..

    Thanks!

  2. #2
    gioarvan is offline Member
    Join Date
    Apr 2011
    Posts
    3
    Rep Power
    0

    Default

    after a little search i found thet i have to use
    <fmt:parseDate value="${start_date}" type="DATE" pattern="dd-MM-yy" var="start_date"/>
    to format the mysql date to a java.util.date, so far so good...but i cant compare them using JSTL like this:

    Current date:
    <jsp:useBean id="date" class="java.util.Date" />
    <fmt:formatDate pattern="dd-MM-yy" type="DATE" value="${date}" />
    <c:set var="curDate" value="${date}"/>

    Start Date
    <fmt:parseDate value="${start_date}" type="DATE" pattern="dd-MM-yy" var="start_date"/>
    <fmt:formatDate value="${start_date}" pattern="dd-MM-yy" type="DATE"/>


    and then


    <c:if test="${(start_date > curDate)}">
    <p>Prosfora2?</p>
    </c:if>


    Not working....any help??

  3. #3
    gioarvan is offline Member
    Join Date
    Apr 2011
    Posts
    3
    Rep Power
    0

    Default

    Ok i found the solution. If someone is interested i can post the code. Cheerz!

Similar Threads

  1. Replies: 12
    Last Post: 04-18-2009, 12:58 AM
  2. Compare date input to database with current date
    By hungleon88 in forum Advanced Java
    Replies: 2
    Last Post: 11-25-2008, 08:10 AM
  3. 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
  4. Inserting current date into a DB table
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 02-15-2008, 08:38 AM
  5. how to get the current date and time
    By valery in forum New To Java
    Replies: 1
    Last Post: 08-03-2007, 06:05 PM

Tags for this Thread

Posting Permissions

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