/**
*
* 方法描述:取得当前日期的上月或下月日期 ,amount=-1为上月日期,amount=1为下月日期;
* @param strDate
* @param format 日期格式 如 yyyy-MM-dd
* @param amount 月份增减参数
* @return
* @throws Exception
*/
public static String getFrontBackStrDate(String strDate, String format, int amount) throws Exception {
if (null == strDate) {
return null;
}
try {
DateFormat fmt = new SimpleDateFormat(format);
Calendar c = Calendar.getInstance();
c.setTime(fmt.parse(strDate));
c.add(Calendar.MONTH, amount);
return fmt.format(c.getTime());
} catch (Exception e) {
e.printStackTrace();
}
return "";
}
*
* 方法描述:取得当前日期的上月或下月日期 ,amount=-1为上月日期,amount=1为下月日期;
* @param strDate
* @param format 日期格式 如 yyyy-MM-dd
* @param amount 月份增减参数
* @return
* @throws Exception
*/
public static String getFrontBackStrDate(String strDate, String format, int amount) throws Exception {
if (null == strDate) {
return null;
}
try {
DateFormat fmt = new SimpleDateFormat(format);
Calendar c = Calendar.getInstance();
c.setTime(fmt.parse(strDate));
c.add(Calendar.MONTH, amount);
return fmt.format(c.getTime());
} catch (Exception e) {
e.printStackTrace();
}
return "";
}