试一试 把日期都转换成Date DQRQ = rs.getDate(1);  
long time=DQRQ.getTime();
time=time+strTo;
Date  DQRQ=new Date(time);is this OK?

解决方案 »

  1.   

    其实把类型转换以后比较就可以了不管是date型,还是long型
      

  2.   

    谢谢你的回复先,呵呵,有错误的说....---------- compile package ----------
    UserAManageBean.java:62: reference to Date is ambiguous, both class java.util.Date in java.util and class java.sql.Date in java.sql match
      Date DQRQ = rs.getDate(1);
                              ^
    UserAManageBean.java:68: cannot resolve symbol
    symbol  : variable time 
    location: class NetBalance.logic.UserAManageBean
      if ((userPwd.equals(pwd)) && (time>System.currentTimeMillis()))
                                                    ^
    UserAManageBean.java:71: cannot resolve symbol
    symbol  : variable time 
    location: class NetBalance.logic.UserAManageBean
      } else if ((userPwd.equals(pwd)) && (time<System.currentTimeMillis()))
                                                           ^
    3 errors输出完成 (耗时 6 秒) - 正常终止
      

  3.   

    回复人: czcui1979(WAS害人) ( ) 信誉:100  2004-10-11 13:06:00  得分: 0  
     
     
       其实把类型转换以后比较就可以了不管是date型,还是long型---------------------------惭愧,我刚接触java不久,有些东西了解的太肤浅,能说得详细点吗? 
     
      

  4.   


      //形成当前时间字符串形式
      public String getCurDateStr()
      {
        //得到系统时间
        SimpleDateFormat f=new SimpleDateFormat("MM dd yyyy");
        String sDate=f.format(new Date());
        return sDate;
      }
      

  5.   

      rs = db.executeQuery(sql2);
      if (rs.next())
      {
      Calendar DQRQ = Calendar.getInstance();
      DQRQ.setTime(rs.getDate(1));  //把Date转换为Calendar
      DQRQ.add(Calendar.DATE,strTo);  //这样就可以了
      }   if ((userPwd.equals(pwd)) && (DQRQ.getTimeInMillis() > System.currentTimeMillis()))    //???(DQRQ.getTime()>System.currentTimeMillis()))    怎么进行比较?
      {
      verifyPwd = 1;
      } else if ((userPwd.equals(pwd)) && (DQRQ.getTime()<System.currentTimeMillis()))
      {
      verifyPwd = 2;
      }
      

  6.   

    ---------- compile package ----------
    UserAManageBean.java:67: cannot resolve symbol
    symbol  : variable DQRQ 
    location: class NetBalance.logic.UserAManageBean
      if ((userPwd.equals(pwd)) && (DQRQ.getTimeInMillis()>System.currentTimeMillis()))
                                                    ^
    UserAManageBean.java:70: cannot resolve symbol
    symbol  : variable DQRQ 
    location: class NetBalance.logic.UserAManageBean
      } else if ((userPwd.equals(pwd)) && (DQRQ.getTimeInMillis()<System.currentTimeMillis()))
                                                           ^
    2 errors输出完成 (耗时 7 秒) - 正常终止----------------------
     Tasia(这里是CSDN吗?)   谢谢你的解答...
     
    但现在提示这个错误.这是为啥....
      

  7.   

    Calendar DQRQ = Calendar.getInstance();
    DQRQ.setTime(rs.getDate(1).getTime());  //???这里怎么对日期进行处理
      
    DQRQ.add(Calendar.DATE,strTo);  //???这里怎么把strTo加到DQRQ(到期日期)
    if ((userPwd.equals(pwd)) && (DQRQ.getTimeInMillis()>System.currentTimeMillis()))    //???(DQRQ.getTimeInMillis()>System.currentTimeMillis()))    怎么进行比较?
      

  8.   

    晕啊...我是一模一样的敲上去的啊....
    还是提示这个错误...这是为什么啊....?   *_*
    ------------------------------
    ---------- compile package ----------
    UserAManageBean.java:67: cannot resolve symbol
    symbol  : variable DQRQ 
    location: class NetBalance.logic.UserAManageBean
      if ((userPwd.equals(pwd)) && (DQRQ.getTimeInMillis()>System.currentTimeMillis()))
                                                    ^
    UserAManageBean.java:70: cannot resolve symbol
    symbol  : variable DQRQ 
    location: class NetBalance.logic.UserAManageBean
      } else if ((userPwd.equals(pwd)) && (DQRQ.getTimeInMillis()<System.currentTimeMillis()))
                                                           ^
    2 errors输出完成 (耗时 3 秒) - 正常终止
      

  9.   

    variable DQRQ的问题,很明显了啊!
      

  10.   

    回复人: skyboy0720(神仙?妖怪?谢谢!) ( ) 信誉:96  2004-10-11 15:11:00  得分: 0  
     
     
       记得import java.util.Calendar;
     
     
    ---------------------谢谢你的回复先,我加了啊....所以不知道哪出的错.郁闷死了!
      

  11.   

    DQRQ是在if里定义的,不能在if外引用
      

  12.   

    回复人: wchar(9527) ( ) 信誉:98  2004-10-11 15:49:00  得分: 0  
     
     
       DQRQ是在if里定义的,不能在if外引用
     
     
    --------------------就是这样....谢谢啊!!! 
    呵呵,谢谢大家....   晚上回家了结帖...