[code]
/**
* 获取今天前后几天的日期,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);
}
[/code]
/**
* 获取今天前后几天的日期,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);
}
[/code]