Package org.springframework.format.number

Examples of org.springframework.format.number.NumberFormatter


    assertNull(formattingService.convert("", TypeDescriptor.valueOf(String.class), TypeDescriptor.valueOf(Integer.class)));
  }

  @Test
  public void testParseBlankString() throws ParseException {
    formattingService.addFormatterForFieldType(Number.class, new NumberFormatter());
    assertNull(formattingService.convert("     ", TypeDescriptor.valueOf(String.class), TypeDescriptor.valueOf(Integer.class)));
  }
View Full Code Here


    assertNull(formattingService.convert("1", TypeDescriptor.valueOf(String.class), TypeDescriptor.valueOf(Integer.class)));
  }

  @Test(expected=ConversionFailedException.class)
  public void testParseNullPrimitiveProperty() throws ParseException {
    formattingService.addFormatterForFieldType(Integer.class, new NumberFormatter());
    assertNull(formattingService.convert(null, TypeDescriptor.valueOf(String.class), TypeDescriptor.valueOf(int.class)));
  }
View Full Code Here

                final char groupingSeparator = symbols.getGroupingSeparator();
                if (groupingSeparator == '\u00a0') {
                    source = source.replaceAll(" ", Character.toString('\u00a0'));
                }

                final NumberFormatter numberFormatter = new NumberFormatter();
                final Number parsedNumber = numberFormatter.parse(source, clientApplicationLocale);
                if (parsedNumber instanceof BigDecimal) {
                    number = (BigDecimal) parsedNumber;
                } else {
                    number = BigDecimal.valueOf(Double.valueOf(parsedNumber.doubleValue()));
                }
View Full Code Here

TOP

Related Classes of org.springframework.format.number.NumberFormatter

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.