zhangjia_pri
2013-01-17 09:32:35
Java日期操作工具类
这里有常用的一些日期处理的方法,写的算是很全面的了,希望有人可以把自己写的好的日期处理的代码更新到里面
截取一段代码如下:
/** * 判断日期是否有效,包括闰年的情况 * * @param date * YYYY-mm-dd * @return */ public static boolean isDate(String date) { StringBuffer reg = new StringBuffer( "^((\\d{2}(([02468][048])|([13579][26]))-?((((0?"); reg.append("[13578])|(1[02]))-?((0?[1-9])|([1-2][0-9])|(3[01])))"); reg.append("|(((0?[469])|(11))-?((0?[1-9])|([1-2][0-9])|(30)))|"); reg.append("(0?2-?((0?[1-9])|([1-2][0-9])))))|(\\d{2}(([02468][12"); reg.append("35679])|([13579][01345789]))-?((((0?[13578])|(1[02]))"); reg.append("-?((0?[1-9])|([1-2][0-9])|(3[01])))|(((0?[469])|(11))"); reg.append("-?((0?[1-9])|([1-2][0-9])|(30)))|(0?2-?((0?["); reg.append("1-9])|(1[0-9])|(2[0-8]))))))"); Pattern p = Pattern.compile(reg.toString()); return p.matcher(date).matches(); }
由AXIN编辑于2014-2-22 12:30:54
由最代码官方编辑于2014-10-22 9:52:36
猜你喜欢
请下载代码后再发表评论
![最代码相关代码源代码列表](https://static.zuidaima.com/resource/img/heart_ico.png)
![最代码最近下载分享源代码列表](https://static.zuidaima.com/resource/img/heart_ico.png)
2219318029 LV1
2020年6月25日
cvsFeng LV21
2016年9月23日
你是我的眼 LV11
2015年7月29日
尘封烈焰 LV2
2014年10月23日
AXIN LV36
2014年2月22日
![最代码最近浏览分享源代码列表](https://static.zuidaima.com/resource/img/cattle_ico.png)
andy22
2021年3月27日
暂无贡献等级
2219318029 LV1
2020年6月25日
wei112233 LV15
2020年4月21日
zhoujie123800 LV6
2020年2月18日
nextstep LV11
2020年1月7日
白云天空的对白 LV3
2019年9月27日
jlmarket LV22
2019年8月21日
ll1542804005 LV6
2019年7月19日
tanscofield LV1
2018年12月20日
wmjwh007 LV1
2018年12月12日