解决方案 »

  1.   

    public static void main(String[] args) throws IOException {
    Date now = new Date();
    SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
    Calendar calendar = new GregorianCalendar();
    calendar.setTime(now);
    calendar.add(calendar.DATE, 25);// +25天
    System.out.println("今天的日期+25天:" + format.format(calendar.getTime()));
    }
      

  2.   

    Calendar可以,为什么new Date(Long l)加减会出错,不明白原因
      

  3.   

    25 * 24 * 60 * 60 * 1000 超出了int 的范围了,已经溢出了
    System.out.println(24 * 24 * 60 * 60 * 1000);
    System.out.println(Integer.MAX_VALUE);
    System.out.println(25 * 24 * 60 * 60 * 1000);
    2073600000
    2147483647
    -2134967296
    想使用这种方式的话,可以
    25L * 24 * 60 * 60 * 1000
    99L * 24 * 60 * 60 * 1000
    先转换为long 类型,然后就不会出错了
      

  4.   

    OK,解决了。还真没想到是Integer值溢出。谢谢指导。