OT Locale on macOS High Sierra

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

OT Locale on macOS High Sierra

Andreas Ernst
Hi,

anybody issues with the Locale on macOS HighSierra?

Locale locale = Locale.getDefault();
System.out.println("Locale.getDefault(): " + locale);
Calendar caldat = Calendar.getInstance(locale);
TimeZone TimeZone;
DateFormat dateFormat =
java.text.DateFormat.getDateTimeInstance(java.text.DateFormat.MEDIUM,
java.text.DateFormat.MEDIUM, locale);
System.out.println("Locale    " + caldat.getTimeZone());
System.out.println("Timestamp " + dateFormat.format(caldat.getTime()));
dateFormat =
java.text.DateFormat.getDateTimeInstance(java.text.DateFormat.MEDIUM,
java.text.DateFormat.MEDIUM);
System.out.println("Timestamp " + dateFormat.format(caldat.getTime()));
NumberFormat nf = NumberFormat.getNumberInstance();
DecimalFormat formatter = (DecimalFormat) nf;
formatter.applyPattern("#,###,##0.00");
BigDecimal n = new BigDecimal("123132132");
System.out.println(formatter.format(n));
nf = NumberFormat.getNumberInstance(locale);
formatter = (DecimalFormat) nf;
formatter.applyPattern("#,###,##0.00");
System.out.println(formatter.format(n));


Locale.getDefault(): de_DE
Locale
sun.util.calendar.ZoneInfo[id="Europe/Berlin",offset=3600000,dstSavings=3600000,useDaylight=true,transitions=143,lastRule=java.util.SimpleTimeZone[id=Europe/Berlin,offset=3600000,dstSavings=3600000,useDaylight=true,startYear=0,startMode=2,startMonth=2,startDay=-1,startDayOfWeek=1,startTime=3600000,startTimeMode=2,endMode=2,endMonth=9,endDay=-1,endDayOfWeek=1,endTime=3600000,endTimeMode=2]]
Timestamp 10.10.2017 11:02:33
Timestamp Oct 10, 2017 11:02:33 AM
123,132,132.00
123.132.132,00

It seems that you have to set the default Locale. On macOS Sierra and
before it is working without setting the Locale.

Andreas
--
ae | Andreas Ernst | IT Spektrum
Postfach 5, 65612 Beselich
Schupbacher Str. 32, 65614 Beselich, Germany
Tel: +49-6484-91002 Fax: +49-6484-91003
[hidden email] | www.ae-online.de
www.tachyon-online.de