怎么了?
public String toString() {
return super.toString()
+ String.format(" %1$F-%2$F", startDate, endDate);
}
我明白了
Caused by: java.util.UnknownFormatConversionException: Conversion = ‘F’
at java.util.Formatter$FormatSpecifier.conversion(Formatter.java:2606)
at java.util.Formatter$FormatSpecifier.(Formatter.java:2634)
at java.util.Formatter.parse(Formatter.java:2480)
at java.util.Formatter.format(Formatter.java:2414)
at java.util.Formatter.format(Formatter.java:2367)
at java.lang.String.format(String.java:2769)
我想打印java.util.Formatter
中定义的ISO 8601日期
解决方法:
我认为日期格式化模式需要一个前缀:
't', 'T' date/time Prefix for date and time conversion characters. See Date/Time Conversions.
F修饰符的示例还显示了以下语法:
'F' ISO 8601 complete date formatted as "%tY-%tm-%td".
所以以下模式应该有效:
String.format(" %1$tF-%2$tF", startDate, endDate);