取得指定月份的第一天与取得指定月份的最后一天
浏览:52日期:2023-02-08
内容: 取得指定月份的第一天与取得指定月份的最后一天- - /** * 取得指定月份的第一天 * * @param strdate String * @return String */ public String getMonthBegin(String strdate) { java.util.Date date = parseFormatDate(strdate); return formatDateByFormat(date,'yyyy-MM') + '-01'; } /** * 取得指定月份的最后一天 * * @param strdate String * @return String */ public String getMonthEnd(String strdate) { java.util.Date date = parseFormatDate(getMonthBegin(strdate)); Calendar calendar = Calendar.getInstance(); calendar.setTime(date); calendar.add(Calendar.MONTH,1); calendar.add(Calendar.DAY_OF_YEAR, -1); return formatDate(calendar.getTime()); } /** * 常用的格式化日期 * * @param date Date * @return String */ public String formatDate(java.util.Date date) { return formatDateByFormat(date,'yyyy-MM-dd'); } /** * 以指定的格式来格式化日期 * * @param date Date * @param format String * @return String */ public String formatDateByFormat(java.util.Date date,String format) { String result = ''; if(date != null) { try { SimpleDateFormat sdf = new SimpleDateFormat(format); result = sdf.format(date); } catch(Exception ex) { LOGGER.info('date:' + date); ex.printStackTrace(); } } return result; } Java, java, J2SE, j2se, J2EE, j2ee, J2ME, j2me, ejb, ejb3, JBOSS, jboss, spring, hibernate, jdo, struts, webwork, ajax, AJAX, mysql, MySQL, Oracle, Weblogic, Websphere, scjp, scjd 取得指定月份的第一天与取得指定月份的最后?
相关文章:
热门推荐
- meta http-equiv='X-UA-Compatible' content='IE=7' 意思是将IE8用IE7进行渲染
- 1.hbuilder配置nodejs
- 2.hbuildercss怎么用
- 3.golang 输出重定向:fmt Log,子进程Log,第三方库logrus的详解
- 4.JS 逻辑判断不要只知道用 if-else 和 switch条件判断(小技巧)
- 5.在ASP.NET中存取图片到数据库的示例
- 6.如何在FreeBSD上用PHP实现在线添加FTP用户
- 7.在Flash中使用ASP技术
- 8.js完美解决IE6不支持position:fixed的bug
- 9.ASP 3.0高级编程(二十五)
- 10.JSP乱码解决大全