What's wrong with
public String toString() {
return super.toString()
+ String.format(" %1$F-%2$F", startDate, endDate);
}
I get
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)
I wanted to print the ISO 8601 date defined in java.util.Formatter
I think the date formatting patterns require a prefix:
't', 'T' date/time Prefix for date and time conversion characters. See Date/Time Conversions.
The example for the F
modifier also shows this syntax:
'F' ISO 8601 complete date formatted as "%tY-%tm-%td".
So the following pattern should work:
String.format(" %1$tF-%2$tF", startDate, endDate);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With