Bug in parsing of strings in DateFormatSymbols
Guillermo Rodriguez Garcia <[email protected]> Mon, 22 Jan 2018 12:28:19 +0100
| Newsgroups | gmane.comp.java.classpath.devel |
|---|---|
| Message-ID | <CABDcavY205y91KnSpFczZAUgTB7PzywmPF=XB9Gda4fJOVA-2A@mail.gmail.com> |
--001a114440bc309b9a05635bbae4
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Hello all,
There is a bug in the parsing of strings in DateFormatSymbols. In many
locales, some strings (such as the "eras" and "ampms" string) have an
additional field separator at the end, and
DateFormatSymbols.getStringArray() does not handle this properly.
As a result, formatting dates result in strings like this:
Date date =3D new Date(118, 0, 22, 18, 20);
SimpleDateFormat df =3D new SimpleDateFormat("MM/dd/yyyy h:mm aa");
System.out.println(df.format(date));
// Prints: 01/22/3918 6:20 PM=C2=AE <-- See trailing =C2=AE character
I have created a bug report in bugzilla including a test case and proposed
fix:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D83968
Best,
Guillermo Rodriguez Garcia
[email protected]
--001a114440bc309b9a05635bbae4
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">Hello all,<div><br></div><div>There is a bug in the parsin=
g of strings in DateFormatSymbols. In many locales, some strings (such as t=
he "eras" and "ampms" string) have an additional field =
separator at the end, and DateFormatSymbols.getStringArray() does not handl=
e this properly.</div><div><br>As a result, formatting dates result in stri=
ngs like this:</div><div><br></div><div><div><span class=3D"gmail-Apple-tab=
-span" style=3D"white-space:pre"> </span>Date date =3D new Date(118, 0, 22=
, 18, 20);</div><div><span class=3D"gmail-Apple-tab-span" style=3D"white-sp=
ace:pre"> </span>SimpleDateFormat df =3D new SimpleDateFormat("MM/dd/=
yyyy h:mm aa");</div><div><span class=3D"gmail-Apple-tab-span" style=
=3D"white-space:pre"> </span>System.out.println(df.format(date));</div><di=
v><span class=3D"gmail-Apple-tab-span" style=3D"white-space:pre"> </span><=
/div><div><span class=3D"gmail-Apple-tab-span" style=3D"white-space:pre"> =
</span>// Prints: 01/22/3918 6:20 PM=C2=AE <-- See trailing =C2=AE chara=
cter</div><div><br></div><div>I have created a bug report in bugzilla inclu=
ding a test case and proposed fix:=C2=A0</div><div><br></div><div><a href=
=3D"https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D83968">https://gcc.gnu.o=
rg/bugzilla/show_bug.cgi?id=3D83968</a><br></div><div><br></div><div>Best,<=
/div><div><br></div><div class=3D"gmail_signature">Guillermo Rodriguez Garc=
ia<br><a href=3D"mailto:[email protected]" target=3D"_blank">guill=
[email protected]</a></div>
</div></div>
--001a114440bc309b9a05635bbae4--