//设置日期(在当前日期之前/之后 由参数定[正数在之后 负数在之前])
public static String dataParam(String datastr,int timedifference)
{
try
{
SimpleDateFormat sdf =new SimpleDateFormat("yyyy-MM-dd");
Calendar cal = Calendar.getInstance();
if(null!=datastr)
{
cal.setTime(sdf.parse(datastr));
}
cal.add(Calendar.DAY_OF_MONTH, timedifference);
return sdf.format(cal.getTime());
}
catch(Exception ex)
{
return null;
}
}
如果datastr是null的话,那么计算的将是当前日期