/**
	 * 获取今天前后几天的日期,pn 为整数
	 * */
	public String privOrNextDate(int pn)
	{
		Calendar cal = Calendar.getInstance();
		cal.add(Calendar.DATE, pn);
		return new SimpleDateFormat("yyyy-MM-dd").format(cal.getTime());
	}

/**
	 * 取得指定日期前后几天的日期
	 */
	public String datePreOrNext(String date, int pOrN)
	{
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
		Date thisdate = new Date();
		ParsePosition pp = new ParsePosition(0);
		try
		{
			thisdate = sdf.parse(date, pp);
			thisdate.setTime(((thisdate.getTime() / 1000) + (60 * 60 * 24) * pOrN) * 1000);
		} catch (Exception e)
		{
			e.printStackTrace();
		}
		return sdf.format(thisdate);
	}
评论
daoger 2007-09-28
只是觉得需要的时候查询方便一点,以后还会添加更新的!
daoger 2007-09-26
这是我自己写的,欢迎提出更好的方法!
thoriod 2007-09-26
这个方法并不怎么好啊。05
发表评论

您还没有登录,请登录后发表评论

daoger
  • 浏览: 190915 次
  • 性别: Icon_minigender_1
  • 来自: 山东济南
  • 详细资料
搜索本博客
我的相册
Fe9b8bf5-5e8b-35c4-ad80-88fec768d45c-thumb
image007
共 105 张
存档
最新评论