List of usage examples for java.util Locale getDefault
public static Locale getDefault(Locale.Category category)
From source file:Main.java
/** * Converts a LocalDate (ISO) value to a ChronoLocalDate date using the * provided Chronology, and then formats the ChronoLocalDate to a String using * a DateTimeFormatter with a SHORT pattern based on the Chronology and the * current Locale.// w w w .j ava 2 s.co m * * @param localDate * - the ISO date to convert and format. * @param chrono * - an optional Chronology. If null, then IsoChronology is used. */ public static String toString(LocalDate localDate, Chronology chrono) { if (localDate != null) { Locale locale = Locale.getDefault(Locale.Category.FORMAT); ChronoLocalDate cDate; if (chrono == null) { chrono = IsoChronology.INSTANCE; } try { cDate = chrono.date(localDate); } catch (DateTimeException ex) { System.err.println(ex); chrono = IsoChronology.INSTANCE; cDate = localDate; } String pattern = "M/d/yyyy GGGGG"; DateTimeFormatter dateFormatter = DateTimeFormatter.ofPattern(pattern); return dateFormatter.format(cDate); } else { return ""; } }