开发者

DateUtils.parseDate doesn't throw ParseException on invalid dates

java.util.date 开发者_运维技巧= org.apache.commons.lang.time.DateUtils.parseDate(value, new String[] { "mm/dd/yyyy" });

If you give an invalid date string (e.g. value = 13/02/2000 or value = "12/35/2000"), this didn't result in an error (e.g. 13 as a month is invalid and 35 as a date is invalid). But the above function just moved the appropriate date | month bits and gave a date which was correct. Is there a function which will throw a ParseException in such cases?


DateUtils.parseDateStrictly(String, String[]) FTW!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜