Package jodd.typeconverter.impl

Examples of jodd.typeconverter.impl.FloatConverter


    ByteConverter byteConverter = new ByteConverter();
    register(Byte.class, byteConverter);
    register(byte.class, byteConverter);
    register(MutableByte.class, new MutableByteConverter(this));

    FloatConverter floatConverter = new FloatConverter();
    register(Float.class, floatConverter);
    register(float.class, floatConverter);
    register(MutableFloat.class, new MutableFloatConverter(this));

    DoubleConverter doubleConverter = new DoubleConverter();
View Full Code Here


    ByteConverter byteConverter = new ByteConverter();
    register(Byte.class, byteConverter);
    register(byte.class, byteConverter);
    register(MutableByte.class, new MutableByteConverter(this));

    FloatConverter floatConverter = new FloatConverter();
    register(Float.class, floatConverter);
    register(float.class, floatConverter);
    register(MutableFloat.class, new MutableFloatConverter(this));

    DoubleConverter doubleConverter = new DoubleConverter();
View Full Code Here

public class FloatConverterTest {

  @Test
  public void testConversion() {
    FloatConverter floatConverter = new FloatConverter();

    assertNull(floatConverter.convert(null));

    assertEquals(Float.valueOf(1), floatConverter.convert(Integer.valueOf(1)));
    assertEquals(Float.valueOf((float) 1.73), floatConverter.convert(Double.valueOf(1.73D)));
    assertEquals(Float.valueOf((float) 1.73), floatConverter.convert("1.73"));
    assertEquals(Float.valueOf((float) 1.73), floatConverter.convert(" 1.73 "));
    assertEquals(Float.valueOf((float) 1.73), floatConverter.convert(" +1.73 "));
    assertEquals(Float.valueOf((float) -1.73), floatConverter.convert(" -1.73 "));
    assertEquals(Float.valueOf((float) 1.73), floatConverter.convert(new BigDecimal("1.73")));

    try {
      floatConverter.convert("aaaa");
      fail();
    } catch (TypeConversionException ignore) {
    }
  }
View Full Code Here

TOP

Related Classes of jodd.typeconverter.impl.FloatConverter

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.