怎樣獲取n天后的系統時間
不知道有沒有具體的方法可以直接調用?
還是庶先獲取當前系統時間﹐然后+n天﹐去考慮大小月﹐平閏年的計算?

解决方案 »

  1.   

    此回复为自动发出,仅用于显示而已,并无任何其他特殊作用
    楼主【aihua_z】截止到2008-06-26 12:37:59的历史汇总数据(不包括此帖):
    发帖数:1                  发帖分:10                 
    结贴数:1                  结贴分:10                 
    未结数:0                  未结分:0                  
    结贴率:100.00%            结分率:100.00%            
    敬礼!
      

  2.   

    获取当前时间,加上n天就好了,Java中的date会自动考虑大小月的问题,不用自己考虑了
      

  3.   

    JAVA、JS都有当前时间加天数的方法,不用考虑什么大小月等
      

  4.   

    Date nowDay = new Date();//當前時間
    Date newDay = nowDay+n;//n天后的時間
    是這樣么?
      

  5.   


    <script>
    var now=new Date();
    alert(now);
    now.setDate(now.getDate()+100);
    alert(now);
    </script>
      

  6.   

    int n = 3;
    Calendar theCa = Calendar.getInstance();
     theCa.setTime(new Date());
     theCa.add(theCa.DATE, n);
     Date date = theCa.getTime();
    3天后的日期
      

  7.   


    theCa.setTime(new Date()); 
    還有這個干什么用的?沒這句不是也可以么?
      

  8.   


    /**
     * 得到给定日期N天后的日期
     * @param num
     * @return
     */
    public static void do4(String datestr,int num) {
    String pattern = "yyyy-MM-dd";
    SimpleDateFormat format = new SimpleDateFormat(pattern);
    try{
    Date getdate = format.parse(datestr);
    long time = getdate.getTime()+(1000L * 60 * 60 * 24 * num);
    Date date = new Date();
    if (time > 0) {
    date.setTime(time);
    }
    System.out.println(format.format(date));
    }catch(Exception e){}
    }刚才也有个人在问,我一发,他结帖了,那这个就给你吧,
      

  9.   


      /**
         * 得到N天后的日期
         * @param num
         * @return
         */
        public static String getDate(int num) {
            long time = System.currentTimeMillis() + (1000L * 60 * 60 * 24 * num);
            String pattern = "yyyy-MM-dd";
            Date date = new Date();
            if (time > 0) {
                date.setTime(time);
            }
            SimpleDateFormat format = new SimpleDateFormat(pattern);
            return format.format(date);
        }
    这两个都可以,
      

  10.   

    我做的是JSPint n = 3; 
    Calendar theCa = Calendar.getInstance(); 
    theCa.setTime(new Date()); 
    theCa.add(theCa.DATE, n); 
    Date date = theCa.getTime(); 這個好像適合我用﹐就是theCa.setTime(new Date()); 不知道干什么用的
      

  11.   

    theCa.setTime(new Date()); 可以不要的
    Calendar.getInstance(); 取得就是当天时间了
    new Date()也一样 只是取出的时间类型不一样罢了