简体   繁体   English

使用joda-time将字符串转换为日期时发生IllegalArgumentException

[英]IllegalArgumentException when using joda-time to convert string to date

I have a code as below to convert a string to date: 我有如下代码将字符串转换为日期:

DateTimeFormatter formatter = org.joda.time.format.DateTimeFormat.forPattern("MM/dd/yyyy");
LocalDate checkInDate = LocalDate.parse("08/25/2015");

But when i run the code there is an error: 但是当我运行代码时出现错误:

java.lang.IllegalArgumentException: Invalid format: "08/25/2015" is malformed at "/25/2015" java.lang.IllegalArgumentException:格式无效:“ / 08/25/2015”格式不正确,位于“ / 25/2015”

Anyone can help me resolve this problem. 任何人都可以帮助我解决此问题。

尝试使用格式化程序:

LocalDate checkInDate = formatter.parseLocalDate("08/25/2015");

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM