use of io.jmix.core.metamodel.datatype.FormatStrings in project jmix by jmix-framework.
the class TimeDatatype 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);
}
DateFormat format = new SimpleDateFormat(formatStrings.getTimeFormat());
format.setLenient(false);
return format.format(value);
}
use of io.jmix.core.metamodel.datatype.FormatStrings in project jmix by jmix-framework.
the class DateDatatype 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);
}
DateFormat format = new SimpleDateFormat(formatStrings.getDateFormat());
return format.format(value);
}
use of io.jmix.core.metamodel.datatype.FormatStrings in project jmix by jmix-framework.
the class DoubleDatatype method parse.
@Override
public Double 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.getDoubleFormat(), formatSymbols);
return parse(value, format).doubleValue();
}
use of io.jmix.core.metamodel.datatype.FormatStrings in project jmix by jmix-framework.
the class IntegerDatatype method parse.
@Override
public Integer 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).intValue();
}
use of io.jmix.core.metamodel.datatype.FormatStrings in project jmix by jmix-framework.
the class BigDecimalDatatype 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();
java.text.NumberFormat format = new DecimalFormat(formatStrings.getDecimalFormat(), formatSymbols);
return format.format(value);
}
Aggregations