jimphei学习工作室

jimphei学习工作室

  BlogJava :: 首页 :: 新随笔 :: 联系 :: 聚合  :: 管理 ::
  23 随笔 :: 0 文章 :: 1 评论 :: 0 Trackbacks

java获得指定时间几天前或几天后的日期

[ At 2008-9-15 By abcshadow   1 comment ]

/**
   * 得到几天前的时间
   * @param d
   * @param day
   * @return
   */
  public static Date getDateBefore(Date d,int day){
   Calendar now =Calendar.getInstance();
   now.setTime(d);
   now.set(Calendar.DATE,now.get(Calendar.DATE)-day);
   return now.getTime();
  }
 
  /**
   * 得到几天后的时间
   * @param d
   * @param day
   * @return
   */
  public static Date getDateAfter(Date d,int day){
   Calendar now =Calendar.getInstance();
   now.setTime(d);
   now.set(Calendar.DATE,now.get(Calendar.DATE)+day);
   return now.getTime();
  }

posted on 2009-06-08 14:45 jimphei 阅读(1284) 评论(0)  编辑  收藏

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


网站导航: