List of usage examples for org.springframework.format Parser Parser
Parser
From source file:cherry.foundation.type.format.CustomNumberFormatAnnotationFormatterFactory.java
@Override public Parser<Number> getParser(CustomNumberFormat annotation, Class<?> fieldType) { int value = adjust(annotation.value()); final NumberFormatter formatter = (isNotEmpty(annotation.pattern()) ? new NumberFormatter(annotation.pattern()) : numberFormatter.get(value)); final int scale = (annotation.scale() < 0 ? value : annotation.scale()); return new Parser<Number>() { @Override//from ww w .jav a 2 s . c o m public Number parse(String text, Locale locale) throws ParseException { return NumberUtil.setScale(formatter.parse(text, locale), scale, RoundingMode.DOWN); } }; }