import org.joda.time._
import org.joda.time.format._
val pattern = "MMM d HH:mm:ss Z yyyy"
val input = "Apr 10 18:31:45 +0000 2015"
DateTime.parse(input, DateTimeFormat.forPattern(pattern))
任何人都可以告诉我它为什么不起作用?
我明白了:
DateTime.parse(input, DateTimeFormat.forPattern(pattern))
java.lang.IllegalArgumentException: Invalid format: "Apr 10 18:31:45 +0000 2015"
at org.joda.time.format.DateTimeFormatter.parseDateTime(DateTimeFormatter.java:899)
at org.joda.time.DateTime.parse(DateTime.java:160)
... 43 elided
答案 0 :(得分:2)
val pattern = "MMM d HH:mm:ss Z yyyy"
val input = "Apr 10 18:31:45 +0000 2015"
val format = DateTimeFormat.forPattern(pattern).withLocale(Locale.ENGLISH)
format.parseDateTime(input)
我发现了nvm;)