posts - 23,comments - 12,trackbacks - 0

//import java.text.*;
//import java.util.*;

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,x);
    date=cal.getTime();
    System.out.println("3 days after(or before) is "+format.format(date));
    cal=null;
    return format.format(date);
  }

posted on 2005-08-18 13:26 my java 阅读(5521) 评论(0)  编辑  收藏 所属分类: java

只有注册用户登录后才能发表评论。


网站导航: