例如输入:2005-08-23
输出:2005-08-24
最好能给代码

解决方案 »

  1.   

    //日期加上天数
    public static Date addDate(Date s,int days)
    {
    GregorianCalendar cal = new GregorianCalendar();
    cal.setTime(s);
    cal.add(Calendar.DATE,days);
    Date d = cal.getTime();
        DateFormat df = DateFormat.getDateInstance();
        String a = df.format(d);
        return TypeChange.stringToDate(a);
    }
      

  2.   

    public static String addDay(String s,int n) throws ParseException {
      SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");  Calendar cd = Calendar.getInstance();
      cd.setTime(sdf.parse(s));     
      cd.add(Calendar.DATE, n);
       
      return sdf.format(cd.getTime());
    }
      

  3.   

    不好意思,我对Calendar这个类不是很明白他的用法,有人可以为我讲一下吗????
      

  4.   

    //今天
    Date today = new Date();
    long tdTime = today.getTime();

    //第二天
    long tmTime = tdTime + 1000*24*60*60
    Date tmDate = new Date(tmTime);
      

  5.   

    //返回输入日期+1
      public static String addOneday(String today) {
        SimpleDateFormat f = new SimpleDateFormat("yyyy-MM-dd");
        try {
          Date d = new Date(f.parse(today).getTime()+24*3600*1000 ); //加一天
           return f.format(d);    }
        catch (Exception ex) {
          return "输入格式错误";    //报错
        }
      }