use of io.jmix.core.metamodel.datatype.FormatStrings in project jmix by jmix-framework.
the class FormatStringsLoader method init.
@EventListener(ContextRefreshedEvent.class)
private void init() {
for (Locale locale : coreProperties.getAvailableLocales()) {
String numberDecimalSeparator = getMessage("numberDecimalSeparator", locale);
String numberGroupingSeparator = getMessage("numberGroupingSeparator", locale);
String integerFormat = getMessage("integerFormat", locale);
String doubleFormat = getMessage("doubleFormat", locale);
String decimalFormat = getMessage("decimalFormat", locale);
String dateFormat = getMessage("dateFormat", locale);
String dateTimeFormat = getMessage("dateTimeFormat", locale);
String offsetDateTimeFormat = getMessage("offsetDateTimeFormat", locale);
String timeFormat = getMessage("timeFormat", locale);
String offsetTimeFormat = getMessage("offsetTimeFormat", locale);
String trueString = getMessage("trueString", locale);
String falseString = getMessage("falseString", locale);
if (numberDecimalSeparator.equals("numberDecimalSeparator") || numberGroupingSeparator.equals("numberGroupingSeparator") || integerFormat.equals("integerFormat") || doubleFormat.equals("doubleFormat") || decimalFormat.equals("decimalFormat") || dateFormat.equals("dateFormat") || dateTimeFormat.equals("dateTimeFormat") || offsetDateTimeFormat.equals("offsetDateTimeFormat") || timeFormat.equals("timeFormat") || offsetTimeFormat.equals("offsetTimeFormat"))
log.warn("Localized format strings are not defined for {}", locale);
formatStringsRegistry.setFormatStrings(locale.stripExtensions(), new FormatStrings(numberDecimalSeparator.charAt(0), numberGroupingSeparator.charAt(0), integerFormat, doubleFormat, decimalFormat, dateFormat, dateTimeFormat, offsetDateTimeFormat, timeFormat, offsetTimeFormat, trueString, falseString));
}
}
use of io.jmix.core.metamodel.datatype.FormatStrings in project jmix by jmix-framework.
the class IntegerDatatype method format.
@Override
public String format(Object value, Locale locale) {
if (value == null)
return "";
FormatStrings formatStrings = formatStringsRegistry.getFormatStringsOrNull(locale);
if (formatStrings == null)
return format(value);
DecimalFormatSymbols formatSymbols = formatStrings.getFormatSymbols();
NumberFormat format = new DecimalFormat(formatStrings.getIntegerFormat(), formatSymbols);
return format.format(value);
}
use of io.jmix.core.metamodel.datatype.FormatStrings in project jmix by jmix-framework.
the class LongDatatype method format.
@Override
public String format(Object value, Locale locale) {
if (value == null) {
return "";
}
FormatStrings formatStrings = formatStringsRegistry.getFormatStringsOrNull(locale);
if (formatStrings == null) {
return format(value);
}
DecimalFormatSymbols formatSymbols = formatStrings.getFormatSymbols();
NumberFormat format = new DecimalFormat(formatStrings.getIntegerFormat(), formatSymbols);
return format.format(value);
}
use of io.jmix.core.metamodel.datatype.FormatStrings in project jmix by jmix-framework.
the class LongDatatype method parse.
@Override
public Long parse(String value, Locale locale) throws ParseException {
if (StringUtils.isBlank(value)) {
return null;
}
FormatStrings formatStrings = formatStringsRegistry.getFormatStringsOrNull(locale);
if (formatStrings == null) {
return parse(value);
}
DecimalFormatSymbols formatSymbols = formatStrings.getFormatSymbols();
NumberFormat format = new DecimalFormat(formatStrings.getIntegerFormat(), formatSymbols);
return parse(value, format).longValue();
}
use of io.jmix.core.metamodel.datatype.FormatStrings in project jmix by jmix-framework.
the class TimeDatatype method parse.
@Override
public Date parse(String value, Locale locale) throws ParseException {
if (StringUtils.isBlank(value)) {
return null;
}
FormatStrings formatStrings = formatStringsRegistry.getFormatStringsOrNull(locale);
if (formatStrings == null) {
return parse(value);
}
DateFormat format = new SimpleDateFormat(formatStrings.getTimeFormat());
return format.parse(value.trim());
}
Aggregations