calender 类

 public   static   String   addDate(String   day,int   x)   
      {   
          SimpleDateFormat   format=new   SimpleDateFormat("yyyy/MM/dd");   
          Date   date   =   null;   
          try   
          {   
              date   =   format.parse(day);   
          }   
          catch   (ParseException   ex)   
          {   
              ex.printStackTrace();   
          }   
          if   (date==null)   return   "";   
          Calendar   cal=Calendar.getInstance();   
          cal.setTime(date);   
          cal.add(Calendar.DAY_OF_MONTH,5);//当前日历加5天
          calender.add(Calendar.AM_PM, 5);  //当前日历加5*12小时 
          date=cal.getTime();   
          System.out.println("3   days   after(or   before)   is   "+format.format(date));   
          cal=null;   
          return   format.format(date);   
      }

你可能感兴趣的:(ca)