@Test public void testNewNumberFormat() throws ParseException { assertThatIllegalArgumentException().isThrownBy(() -> of(FRENCH, null, ",.,.,.").newNumberFormat()); assertThatIllegalArgumentException().isThrownBy(() -> of(null, null, ",.,.,.").newNumberFormat()); double value = 1234.5d; NumberFormat f1 = of(FRANCE, null, null).newNumberFormat(); assertThat(f1.parse("1234,5")).isEqualTo(value); assertThat(f1.format(value)).isEqualTo("1" + getGroupingSeparator(f1) + "234,5"); NumberFormat f2 = of(US, null, null).newNumberFormat(); assertThat(f2.parse("1,234.5")).isEqualTo(value); assertThat(f2.format(value)).isEqualTo("1,234.5"); NumberFormat f3 = of(FRANCE, null, "#0.00").newNumberFormat(); assertThat(f3.parse("1234,50")).isEqualTo(value); assertThat(f3.format(value)).isEqualTo("1234,50"); NumberFormat f4 = of(US, null, "#0.00 €").newNumberFormat(); assertThat(f4.parse("1234.50 €")).isEqualTo(value); assertThat(f4.format(value)).isEqualTo("1234.50 €"); }
@NonNull public NumberFormat newNumberFormat() throws IllegalArgumentException { NumberFormat result = !numberPattern.isEmpty() ? new DecimalFormat(numberPattern, DecimalFormatSymbols.getInstance(getLocaleOrDefault())) : NumberFormat.getInstance(getLocaleOrDefault()); return result; }
DataFormat { @NonNull public NumberFormat newNumberFormat() throws IllegalArgumentException { NumberFormat result = !numberPattern.isEmpty() ? new DecimalFormat(numberPattern, DecimalFormatSymbols.getInstance(getLocaleOrDefault())) : NumberFormat.getInstance(getLocaleOrDefault()); return result; } }
DataFormat { @NonNull public NumberFormat newNumberFormat() throws IllegalArgumentException { NumberFormat result = !numberPattern.isEmpty() ? new DecimalFormat(numberPattern, DecimalFormatSymbols.getInstance(getLocaleOrDefault())) : NumberFormat.getInstance(getLocaleOrDefault()); return result; } private  DataFormat(Locale locale, String datePattern, String numberPattern, Void fake); @Deprecated  DataFormat(@Nullable Locale locale, @Nullable String datePattern); @Deprecated  DataFormat(@Nullable Locale locale, @Nullable String datePattern, @Nullable String numberPattern); }
DataFormat { @NonNull public NumberFormat newNumberFormat() throws IllegalArgumentException { NumberFormat result = !numberPattern.isEmpty() ? new DecimalFormat(numberPattern, DecimalFormatSymbols.getInstance(getLocaleOrDefault())) : NumberFormat.getInstance(getLocaleOrDefault()); return result; } private  DataFormat(Locale locale, String datePattern, String numberPattern, Void fake); @Deprecated  DataFormat(@Nullable Locale locale, @Nullable String datePattern); @Deprecated  DataFormat(@Nullable Locale locale, @Nullable String datePattern, @Nullable String numberPattern); @NonNull static DataFormat of(@Nullable Locale locale, @Nullable String datePattern, @Nullable String numberPattern); @NonNull String getNumberPattern(); @NonNull String getDatePattern(); @Nullable Locale getLocale(); @NonNull String getLocaleString(); @Override String toString(); @Override boolean equals(Object obj); @Override int hashCode(); Formatters.@NonNull Formatter<Date> dateFormatter(); Parsers.@NonNull Parser<Date> dateParser(); Formatters.@NonNull Formatter<Number> numberFormatter(); Parsers.@NonNull Parser<Number> numberParser(); @NonNull DateFormat newDateFormat(); @NonNull NumberFormat newNumberFormat(); @Deprecated @NonNull static DataFormat create(@Nullable String locale, @Nullable String datePattern); @Deprecated @NonNull static DataFormat create(@Nullable String locale, @Nullable String datePattern, @Nullable String numberPattern); @Deprecated @NonNull static Parser<Locale> localeParser(); @Deprecated @NonNull static Locale toLocale(@NonNull String str); @Deprecated @Nullable String previewDate(); @Deprecated @NonNull static DateFormat newDateFormat(@Nullable String datePattern, @Nullable Locale locale); @Deprecated @NonNull static NumberFormat newNumberFormat(@Nullable Locale locale); }
DataFormat { @NonNull public NumberFormat newNumberFormat() throws IllegalArgumentException { NumberFormat result = !numberPattern.isEmpty() ? new DecimalFormat(numberPattern, DecimalFormatSymbols.getInstance(getLocaleOrDefault())) : NumberFormat.getInstance(getLocaleOrDefault()); return result; } private  DataFormat(Locale locale, String datePattern, String numberPattern, Void fake); @Deprecated  DataFormat(@Nullable Locale locale, @Nullable String datePattern); @Deprecated  DataFormat(@Nullable Locale locale, @Nullable String datePattern, @Nullable String numberPattern); @NonNull static DataFormat of(@Nullable Locale locale, @Nullable String datePattern, @Nullable String numberPattern); @NonNull String getNumberPattern(); @NonNull String getDatePattern(); @Nullable Locale getLocale(); @NonNull String getLocaleString(); @Override String toString(); @Override boolean equals(Object obj); @Override int hashCode(); Formatters.@NonNull Formatter<Date> dateFormatter(); Parsers.@NonNull Parser<Date> dateParser(); Formatters.@NonNull Formatter<Number> numberFormatter(); Parsers.@NonNull Parser<Number> numberParser(); @NonNull DateFormat newDateFormat(); @NonNull NumberFormat newNumberFormat(); @Deprecated @NonNull static DataFormat create(@Nullable String locale, @Nullable String datePattern); @Deprecated @NonNull static DataFormat create(@Nullable String locale, @Nullable String datePattern, @Nullable String numberPattern); @Deprecated @NonNull static Parser<Locale> localeParser(); @Deprecated @NonNull static Locale toLocale(@NonNull String str); @Deprecated @Nullable String previewDate(); @Deprecated @NonNull static DateFormat newDateFormat(@Nullable String datePattern, @Nullable Locale locale); @Deprecated @NonNull static NumberFormat newNumberFormat(@Nullable Locale locale); static final DataFormat DEFAULT; static final DataFormat ROOT; static final String SEP; }