DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 3 of 3

Thread: comparing dates

  1. #1
    Join Date
    Feb 2005

    comparing dates

    hey i want to know how to compare dates that a user has typed in, a user types the date in the text fields provided and I want to be able to compare them. I dont want any output from the method, which i have currently i want it to just compare dates like "compareTo" does for String. Thanks.

  2. #2
    Join Date
    Oct 2004
    prepare to undergo ****.

    i learned javascript before java, and still tear my hair out over the mostly Deprecated Date class:

    you have to use the more urbane Calendar object:

    methods you'll probably need:
    set(int year, int month, int date)
    /*you do know how to convert String to primitive int, right?*/

    get(Calendar.SATURDAY);//or whatever day/month in all caps


    you make 2 instances of the Calendar object, set their fields with the set() method, then convert them to longs, subtract, then convert the long back to a calendar object, with all the fancy division implied.

    of course, i could be completely off base, and you probably could just do it with the wonderful Date object and compile it with a deprecated sdk, or there could be a method i missed, or you could probably google one up, but there ya go.

    oh, also check out http://www.experts-exchange.com/Prog..._20870994.html

  3. #3
    Join Date
    Sep 2004
    then why dont you just convert the date to a string then use the comparTo() method?
    A kram a day keeps the doctor......guessing

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
Latest Articles
Questions? Contact us.
Web Development
Latest Tips
Open Source

   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center

We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.