例如:日期A 日期B 日期C (格式全为日期型)如果 B 小于A 输出:还没开始 
如果 B 大于C 输出:已经结束否则 正在进行中。
请请教这个怎么实现。我用“>、<”判断不管用!

解决方案 »

  1.   

    分别获得这三个日期的毫秒数,然后进行比较!DATE API 中有这个函数   我忘了  
    呵呵!
      

  2.   

    Calendar now = Calendar.getInstance();
    Calendar auditTime = Calendar.getInstance();auditTime.clear();
    auditTime.setTime(vktask.getEndDate());//vktask.getEndDate()取出的是java.util.Date型if (auditTime.before(now)) {
    }else{
    }
      

  3.   

    目前  日期A 日期B 日期C  格式是:2007-07-28 15:15:00
    而且已经是Date型的了。。怎么判断??
      

  4.   

    可以使用 Date 类的 compareTo() 方法来比较。data1.compareTo(data2); 会返回一个整数值,小于0,这个时间在前;大于0,这个时间在后;等于0,这两个时间相等。
      

  5.   

    SimpleDateFormat s = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    Date date = new Date();
    date = s.parse("2007-06-06 15:15:00");
    Calendar calendar = new Calendar();
    calendar.setTime(date);
    long time = calendar.getTimeInMillis() / 1000;你按照这个思路去做,就可以了
      

  6.   

    写错了,修正如下:SimpleDateFormat s = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    Date date = new Date();
    date = s.parse("2007-06-06 15:15:00");
    Calendar calendar = Calendar.getInstance(TimeZone.getTimeZone("GMT+8:00"));calendar.setTime(date);
    long time = calendar.getTimeInMillis() / 1000;
      

  7.   

    楼上的你那个有问题!
    如果在同一个月里可以实现如果一个是2007-06-06 15:15:00 2007-07-28 15:15:00就不管用了~~~~~~~~===============================
    管用的啊。SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    Date d1 = sdf.parse("2007-06-06 15:15:00");
    Date d2 = sdf.parse("2007-07-28 15:15:00");
    System.out.println(d1.compareTo(d2)); //输出的值是“-1”,说明 d1 在 d2 之前。
    System.out.println(d2.compareTo(d1)); //输出的值是“1”,说明 d2 在 d1 之后。
      

  8.   

    before
    public boolean before(Date when)
    Tests if this date is before the specified date. Parameters:
    when - a date. 
    Returns:
    true if and only if the instant of time represented by this Date object is strictly earlier than the instant represented by when; false otherwise.--------------------------------------------------------------------------------after
    public boolean after(Date when)
    Tests if this date is after the specified date. Parameters:
    when - a date. 
    Returns:
    true if and only if the instant represented by this Date object is strictly later than the instant represented by when; false otherwise.--------------------------------------------------------------------------------
    API
      

  9.   

    同意 bao110908(长牙了,好痛)