ImmoXmlUtils { @SuppressWarnings("Duplicates") public static BigDecimal parseDecimal(String value) { value = StringUtils.trimToNull(value); if (value == null) return null; try { return DatatypeConverter.parseDecimal(value); } catch (NumberFormatException ex) { } try { return BigDecimal.valueOf(NumberUtils.parseNumber(value, Locale.GERMANY).doubleValue()); } catch (NumberFormatException ex) { } throw new IllegalArgumentException("Can't parse decimal value '" + value + "'!"); } private  ImmoXmlUtils(); static ImmoXmlDocument createDocument(InputStream input); static ImmoXmlDocument createDocument(File xmlFile); static ImmoXmlDocument createDocument(String xmlString); static ImmoXmlDocument createDocument(Document doc); @SuppressWarnings("unused") static Marshaller createMarshaller(); @SuppressWarnings("Duplicates") static Marshaller createMarshaller(String encoding, boolean formatted); static Unmarshaller createUnmarshaller(); @SuppressWarnings({"unused", "Duplicates"}) static Element createUserDefinedSimplefield(Document doc, String name, String value); synchronized static JAXBContext getContext(); static DateFormat getDateFormat(); synchronized static ObjectFactory getFactory(); synchronized static void initContext(ClassLoader classloader); static Calendar parseDate(String value); static Calendar parseDateTime(String value); @SuppressWarnings("Duplicates") static BigDecimal parseDecimal(String value); static BigInteger parseInteger(String value); static BigDecimal parsePositiveDecimal(String value); static BigInteger parsePositiveInteger(String value); static String printDate(Calendar value); static String printDateTime(Calendar value); static String printDecimal(BigDecimal value); static String printInteger(BigInteger value); static String printPositiveDecimal(BigDecimal value); static String printPositiveInteger(BigInteger value); @SuppressWarnings("unused")
    final static ImmoXmlVersion VERSION; @SuppressWarnings("unused")
    final static String NAMESPACE; @SuppressWarnings("unused")
    final static String PACKAGE; @SuppressWarnings("unused")
    final static ObjectFactory FACTORY; }
@Test @SuppressWarnings("CatchMayIgnoreException") public void testParseDecimal() { Assert.assertEquals( new BigDecimal("2"), ImmoXmlUtils.parseDecimal("2")); Assert.assertEquals( new BigDecimal("2.5"), ImmoXmlUtils.parseDecimal("2.5")); Assert.assertEquals( new BigDecimal("2.5"), ImmoXmlUtils.parseDecimal("2,5")); Assert.assertNull(ImmoXmlUtils.parseDecimal("")); try { Assert.assertNull(ImmoXmlUtils.parseDecimal(",")); Assert.fail("An exception should have been thrown."); } catch (IllegalArgumentException ex) { } try { Assert.assertNull(ImmoXmlUtils.parseDecimal(".")); Assert.fail("An exception should have been thrown."); } catch (IllegalArgumentException ex) { } try { ImmoXmlUtils.parseDecimal("2 MM"); Assert.fail("An exception should have been thrown."); } catch (IllegalArgumentException ex) { } }