Behavior difference in java.text.DateFormat API between JDK 8 and 9
Naoto Sato
naoto.sato at oracle.com
Tue Apr 4 22:30:16 UTC 2017
Hi Andrew,
The behavior you are observing is the expected one. As in JDK9, the
default locale data is now based on Unicode Consortium's CLDR [1], and
their date/time combined medium format in English contains a comma
between date and time [2].
Naoto
[1]:
http://docs.oracle.com/javase/9/intl/internationalization-enhancements-jdk-9.htm#JSINT-GUID-9DCDB41C-A989-4220-8140-DBFB844A0FCA
[2]:
http://www.unicode.org/cldr/charts/28/by_type/date_&_time.gregorian.html#7a365a21694f0127
On 4/4/17 2:44 PM, Andrew Guibert wrote:
>
>
> Hi all,
>
> My team has observed that the following code produces different output on
> JDK 8 and 9:
>
> import java.text.*;
> import java.util.*;
>
> DateFormat formatter = DateFormat.getDateTimeInstance(DateFormat.SHORT,
> DateFormat.MEDIUM);
> long time = System.currentTimeMillis();
> Date date = new Date(time);
> System.out.println(formatter.format(date));
>
> Output is:
> JDK 9 (b162): 4/4/17, 2:13:38 PM
> JDK 8 (121): 4/4/17 2:14:16 PM
>
> The only difference is that in JDK 9 there is a comma separating the date
> and time, whereas in JDK 8 there is not. I'm not signed up as a
> contributor so I don't think I can open a bug in the OpenJDK bug tracking
> system, so hopefully someone from the OpenJDK team can take care of this
> one for me.
>
> Thanks, Andy Guibert
>
More information about the jdk9-dev
mailing list