Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9207903
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T00:29:33+00:00 2026-06-18T00:29:33+00:00

I am trying to compare dates, on a basic example and cannot work out

  • 0

I am trying to compare dates, on a basic example and cannot work out the best way of doing it.

The below shows grabbing todays date/time and then comparing it in an IF statement. I am sure the format I have hard coded in is wrong, but when outputing the format that is the format it defaults to. So the question is how do I see if one date is lower than the other and how do I format them to date only?

<p>
    <c:set var="testme" value="<%=new java.util.Date()%>"/>
    <b><c:out value="${testme}"/></b>
</p>

<c:if test="${testme lt 'Tue Jan 29 16:02:58 GMT 2013'}">
    <p><b><span class="wrap">Test date is less.</span></b></p>
</c:if>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T00:29:34+00:00Added an answer on June 18, 2026 at 12:29 am

    For starters, don’t mix Scriptlets and taglibs/EL. That’s just recipe for trouble. Use the one or the other and not both. Assuming that you want to go ahead with taglibs/EL, here’s how you could do it:

    <p>
        <jsp:useBean id="today" class="java.util.Date" />
        <b><c:out value="${today}"/></b>
    </p>
    
    <fmt:setLocale value="en_US" />
    <fmt:parseDate var="testdate" value="Tue Jan 29 16:02:58 GMT 2013" pattern="EEE MMM dd HH:mm:ss z yyyy" />
    <c:if test="${today.time gt testdate.time}">
        <p><b><span class="wrap">Test date is less than now.</span></b></p>
    </c:if>
    

    Note that I also fixed some strange contra-logic in variable names and descriptions.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to compare two dates in PHP and figure out how many days
I have the following code below, I'm trying to compare two dates using Joda
I am trying to compare two dates. I have this code which I thought
Possible Duplicate: MVC3 custom validation: compare two dates I am trying to make a
I'm trying to compare 2 dates using javascript. 1 at the end of the
I'm trying to write test that compare some dates. So far i have 2
i was trying to compare the difference between 2 dates, but it seems the
In my application I need to compare two different dates given in below formats.
I trying to compare two dates (DateTime) in nHibernate linq: query = query.Where(l =>
I am trying to compare the dates with time from inside a cell with

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.