如何指定格式字符串以仅从字符串转换日期.就我而言,只有日期部分是相关的
将其构造为DateTime失败:
String dateString = "2009-04-17";
DateTimeFormatter formatter = DateTimeFormat.forPattern("yyyy-MM-dd");
DateTime dateTime = formatter.parseDateTime(dateString);
Run Code Online (Sandbox Code Playgroud)
有错误 java.lang.IllegalArgumentException: Invalid format: "2011-04-17" is too short
可能是因为我应该使用LocalDate.但是,我没有看到任何格式化程序LocalDate.转换String dateString = "2009-04-17";成最好的方法是什么LocalDate(或者如果不是正确的表示则是其他的东西)
谢谢...