4 Replies Latest reply: Dec 2, 2006 3:29 PM by 796440 RSS

    Date earlierthen

    807607
      I have a date class file that does various things to the data one of the things i want it to do is compare to dates and see if the first is earlier then the second:
      public boolean earilerThan(Date other)
           {
                if ((day < other.day) && (month < other.month) && (year < other.year))
                {
                     return true;
                }
                else
                {
                     return false;
                }
           }
      I noticed that this would only work if day month and year were all less then the other date, of course this is wrong as 20,03,85 and 23.03.85 would return false. Can anybody help me with what the correct coding should be to check a date is earlier then another date?
        • 1. Re: Date earlierthen
          800329
          I've answered your question in the other thread allready :)
          • 2. Re: Date earlierthen
            796440
            Don't post the same question multiple times.
            • 3. Re: Date earlierthen
              807607
              technically i didn't post the same question twice the other thread was about another question in the same class so i decided to see if anybody in there could help but because it had so many replies and was not at the top of the thread list i decided to make a new thread asking the question. Still i won't do it again though.
              • 4. Re: Date earlierthen
                796440
                technically i didn't post the same question twice the
                other thread was about another question in the same
                class so i decided to see if anybody in there could
                help but because it had so many replies and was not
                at the top of the thread list i decided to make a new
                thread asking the question. Still i won't do it again
                though.
                Ah, okay. That's fine, but if you do it, please provide a link to the new thread in the original thread, and mention that it's been moved.