Results 1 to 5 of 5

Thread: compare date

  1. #1
    009
    009 is offline Member
    Join Date
    May 2014
    Posts
    22
    Rep Power
    0

    Default compare date

    how can i compare date with following request

    the value date transction must be within the Active date(>= greater than or equal) and inactive date(<= less than) date range

  2. #2
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,224
    Rep Power
    20

    Default Re: compare date

    Date has before() and after() methods.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  3. #3
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    4,354
    Rep Power
    6

    Default Re: compare date

    But the standard compareTo() works just fine too. Perhaps even better since before and after don't account for equality.

    The trap with date comparisons is that dates might or might not also have a time component which can really throw off your results.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  4. #4
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,224
    Rep Power
    20

    Default Re: compare date

    >= is simply !<.

    And both after and before are less typing...:)
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  5. #5
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    4,354
    Rep Power
    6

    Default Re: compare date

    True enough, yet that is less readable IMO. But I stand corrected, it CAN account for equality.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

Similar Threads

  1. Replies: 5
    Last Post: 02-16-2012, 10:26 AM
  2. Help with date compare in calendar
    By aksis in forum New To Java
    Replies: 1
    Last Post: 12-01-2011, 09:48 PM
  3. Compare Mysql date with current date
    By gioarvan in forum JavaServer Pages (JSP) and JSTL
    Replies: 2
    Last Post: 04-24-2011, 06:19 PM
  4. Replies: 3
    Last Post: 11-30-2010, 11:51 PM
  5. Compare date input to database with current date
    By hungleon88 in forum Advanced Java
    Replies: 2
    Last Post: 11-25-2008, 09:10 AM

Posting Permissions

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