Saturday, July 26, 2008

Java: Compare 2 dates

import java.util.Date;

public class CompareDate {
   public static void main(String[] args) {
      Date dt2 = new Date("7/26/2004");
      Date dt3 = new Date("7/25/2004");

      if (dt2.compareTo(dt3) > 0) {
         System.out.println("dt2>dt3");
      } else {
         System.out.println("dt3<=dt2");
      }
   }
}

No comments:


Since 26 July 2008: