A DESCRIPTION OF THE PROBLEM :
The API docs for DateTimeFormatter explains: "The main date-time classes provide two methods - one for formatting, format(DateTimeFormatter formatter), and one for parsing, parse(CharSequence text, DateTimeFormatter formatter)."
Then there is an example:
String text = date.toString(formatter);
LocalDate date = LocalDate.parse(text, formatter);
Error: date.toString(formatter); should be: date.format(formatter);
As explained in the text above there is a "format" method, there is no "toString" method that takes a DateTimeFormatter.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
String text = date.format(formatter);
ACTUAL -
String text = date.toString(formatter);
URL OF FAULTY DOCUMENTATION :
http://docs.oracle.com/javase/8/docs/api/java/time/format/DateTimeFormatter.html
The API docs for DateTimeFormatter explains: "The main date-time classes provide two methods - one for formatting, format(DateTimeFormatter formatter), and one for parsing, parse(CharSequence text, DateTimeFormatter formatter)."
Then there is an example:
String text = date.toString(formatter);
LocalDate date = LocalDate.parse(text, formatter);
Error: date.toString(formatter); should be: date.format(formatter);
As explained in the text above there is a "format" method, there is no "toString" method that takes a DateTimeFormatter.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
String text = date.format(formatter);
ACTUAL -
String text = date.toString(formatter);
URL OF FAULTY DOCUMENTATION :
http://docs.oracle.com/javase/8/docs/api/java/time/format/DateTimeFormatter.html
- duplicates
-
JDK-8062796 java.time.format.DateTimeFormatter error in API doc example
-
- Resolved
-