我试图使用以下模式解析日期字符串:yyMMdd和STRICT解析器如下:
DateTimeFormatter formatter = DateTimeFormatter.ofPattern(dateFormat).withResolverStyle(ResolverStyle.STRICT);
LocalDate.parse(expiryDate, formatter);
Run Code Online (Sandbox Code Playgroud)
我得到以下内容DateTimeParseException:
java.time.format.DateTimeParseException:无法解析文本'160501':无法从TemporalAccessor获取LocalDate:{YearOfEra = 2016,MonthOfYear = 5,DayOfMonth = 1},ISO类型为java.time.format.Parsed
当我切换到默认的解析风格时,即ResolverStyle.SMART允许这样的日期为2月30日.
有人可以帮忙吗?
| 归档时间: |
|
| 查看次数: |
1267 次 |
| 最近记录: |