Java处理日期

日期为字符串类型,先将日期转换为Date类型

      SimpleDateFormat simpledate = new SimpleDateForma("yyyyMMdd");

      Calendar    ca = Calendar.getInstance();
      Date date = simpledate.parse("20070228");
      ca.setTime(date);
      String datetime = simpledate.format(ca.getTime());
      int year = ca.get(Calendar.YEAR);
      int month = ca.get(Calendar.MONTH);
      int day = ca.get(Calendar.DAY_OF_MONTH);
      //算出后一天的日期
      ca.set(year,month,day+1);
      String aftertime = simpledate.format(ca.getTime());
      System.out.println(datetime+"===="+aftertime);

你可能感兴趣的:(java)