我有以下格式的日期作为字符串"04/02/2019 20:27:05"。我正在使用Joda-Time库,并将其转换为DateTime对象。我做了:
"04/02/2019 20:27:05"
Joda-Time
DateTime
DateTime dt = new DateTime("04/02/2019 20:27:05")
但是我收到以下错误:
Invalid format: "04/02/2011 14:42:17" is malformed at "/02/2019 14:42:17"
如何将上述日期转换为DateTime对象?
用途DateTimeFormat:
DateTimeFormat
DateTimeFormatter formatter = DateTimeFormat.forPattern("dd/MM/yyyy HH:mm:ss"); DateTime dt = formatter.parseDateTime(string);