-
Bug
-
Resolution: Fixed
-
P3
-
None
-
b59
-
generic
-
generic
-
Verified
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8084623 | emb-9 | Masayoshi Okutsu | P3 | Resolved | Fixed | team |
JDK-8086844 | 8u65 | Masayoshi Okutsu | P3 | Resolved | Fixed | b01 |
JDK-8076219 | 8u60 | Masayoshi Okutsu | P3 | Resolved | Fixed | b10 |
JDK-8138023 | emb-8u65 | Unassigned | P3 | Resolved | Fixed | b01 |
JDK-8079001 | emb-8u60 | Masayoshi Okutsu | P3 | Resolved | Fixed | team |
The "stand-alone" month names ("LLLL" format) in English are expected to be identical to the "context sensitive" ("MMMM" format) month names, but instead we see only numbers.
This program:
import java.text.*;
import java.util.*;
public class September {
public static void main(String[] args) throws Throwable {
Date date = new SimpleDateFormat("yyyy-MM-dd").parse("2010-09-15");
String[] formats = { "LLLL", "LLL", "LL",
"MMMM", "MMM", "MM",
};
for (String format : formats) {
System.out.println(format + " -> " + new SimpleDateFormat(format, new Locale("en")).format(date));
}
}
}
prints
LLLL -> 0009
LLL -> 009
LL -> 09
MMMM -> September
MMM -> Sep
MM -> 09
but we expect
LLLL -> September
LLL -> Sep
LL -> 09
MMMM -> September
MMM -> Sep
MM -> 09
The month names are handled correctly in e.g. Czech.
Spec says
http://docs.oracle.com/javase/8/docs/api/java/text/SimpleDateFormat.html
"""
Month: If the number of pattern letters is 3 or more, the month is interpreted as text; otherwise, it is interpreted as a number.
"""
Workaround is to check whether LLLL yields a number and fall back to MMMM in that case.
We have to have fall-back code anyways to continue working with jdk7.
This program:
import java.text.*;
import java.util.*;
public class September {
public static void main(String[] args) throws Throwable {
Date date = new SimpleDateFormat("yyyy-MM-dd").parse("2010-09-15");
String[] formats = { "LLLL", "LLL", "LL",
"MMMM", "MMM", "MM",
};
for (String format : formats) {
System.out.println(format + " -> " + new SimpleDateFormat(format, new Locale("en")).format(date));
}
}
}
prints
LLLL -> 0009
LLL -> 009
LL -> 09
MMMM -> September
MMM -> Sep
MM -> 09
but we expect
LLLL -> September
LLL -> Sep
LL -> 09
MMMM -> September
MMM -> Sep
MM -> 09
The month names are handled correctly in e.g. Czech.
Spec says
http://docs.oracle.com/javase/8/docs/api/java/text/SimpleDateFormat.html
"""
Month: If the number of pattern letters is 3 or more, the month is interpreted as text; otherwise, it is interpreted as a number.
"""
Workaround is to check whether LLLL yields a number and fall back to MMMM in that case.
We have to have fall-back code anyways to continue working with jdk7.
- backported by
-
JDK-8076219 SimpleDateFormat formatting of "LLLL" in English is incorrect; should be identical to "MMMM"
- Resolved
-
JDK-8079001 SimpleDateFormat formatting of "LLLL" in English is incorrect; should be identical to "MMMM"
- Resolved
-
JDK-8084623 SimpleDateFormat formatting of "LLLL" in English is incorrect; should be identical to "MMMM"
- Resolved
-
JDK-8086844 SimpleDateFormat formatting of "LLLL" in English is incorrect; should be identical to "MMMM"
- Resolved
-
JDK-8138023 SimpleDateFormat formatting of "LLLL" in English is incorrect; should be identical to "MMMM"
- Resolved