日期工具
来源:互联网 发布:程序员软件 编辑:程序博客网 时间:2024/05/16 19:02
/**
*
* 方法描述:取得当前日期的上月或下月日期 ,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 "";
}
1 0
- 日期工具
- 日期工具
- 工具类-日期工具类
- 日期工具类
- 日期工具类
- 日期工具类
- java日期工具类
- 日期工具类
- 日期工具类
- 日期工具大全
- 一个日期工具类
- 日期工具类
- java日期工具类
- flex 日期工具类
- 工具类:日期处理
- java 日期工具类
- java日期工具
- 日期工具类
- NumberPicker 很炫酷,很简单的控件
- 最最常用的一些设计模式 之 装饰模式
- STL 源码剖析读书笔记三:序列式容器之 vector、list
- Mysql Sql使用二:数据操作(单表)
- 读取文件并写入数据库
- 日期工具
- java集合类深入分析之Queue篇
- C++程序设计语言练习5.1
- EJB 的真面目
- route TCP/IP index
- Ionic 控制返回键
- pandas.read_csv——分块读取大文件
- iOS开发tableView实现单选和复选
- UiAutomator获取webview里面ui元素的方法