Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8072029 | 9 | Roger Riggs | P4 | Resolved | Fixed | b50 |
JDK-8084465 | emb-9 | Roger Riggs | P4 | Resolved | Fixed | team |
JDK-8130974 | 8u65 | Roger Riggs | P4 | Resolved | Fixed | b05 |
JDK-8138280 | emb-8u65 | Unassigned | P4 | Resolved | Fixed | b05 |
JDK-8130581 | emb-8u60 | Roger Riggs | P4 | Resolved | Fixed | b22 |
The description for the DateTimeFormatter provides two Java snippets which have several issues.
These are those two examples:
First example:
String text = date.toString(formatter);
LocalDate date = LocalDate.parse(text, formatter);
Second example:
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy MM dd");
String text = date.toString(formatter);
LocalDate date = LocalDate.parse(text, formatter);
The Issues:
[1] There is no need to provide both examples in the description; the second is sufficient.
[2] Both examples are invalid Java.
[3] Both examples reference a variable name "date" before it is declared.
[4] Both examples pass method "toString()" a "DateTimeFormatter" argument, but no such method exists in the JDK. Presumably the calls should be to method format() rather than toString().
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
A clearer and valid example for the DateTimeFormatter documentation might be:
LocalDate date1 = LocalDate.of(2014, 10, 25);
System.out.println("date1: " + date1.toString());
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy MM dd");
String text = date1.format(formatter);
LocalDate date2 = LocalDate.parse(text, formatter);
System.out.println("date2: " + date2.toString());
ACTUAL -
The following erroneous text appears in the DateTimeFormatter documentation:
String text = date.toString(formatter);
LocalDate date = LocalDate.parse(text, formatter);
.....
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy MM dd");
String text = date.toString(formatter);
LocalDate date = LocalDate.parse(text, formatter);
URL OF FAULTY DOCUMENTATION :
http://docs.oracle.com/javase/8/docs/api/java/time/format/DateTimeFormatter.html
- backported by
-
JDK-8072029 java.time.format.DateTimeFormatter error in API doc example
-
- Resolved
-
-
JDK-8084465 java.time.format.DateTimeFormatter error in API doc example
-
- Resolved
-
-
JDK-8130581 java.time.format.DateTimeFormatter error in API doc example
-
- Resolved
-
-
JDK-8130974 java.time.format.DateTimeFormatter error in API doc example
-
- Resolved
-
-
JDK-8138280 java.time.format.DateTimeFormatter error in API doc example
-
- Resolved
-
- duplicates
-
JDK-8057798 java.time.format.DateTimeFormatter error in API doc example
-
- Closed
-
-
JDK-8077105 DateTimeFormatter javadoc has error in example
-
- Closed
-
-
JDK-8077105 DateTimeFormatter javadoc has error in example
-
- Closed
-