JAXB Bigdecimal/BigInteger adapter
JAXB BigDecimal / BigInteger apapters Jaxb NumberFormatException XML attributes represents null values with empty string. During unmarshalling an XML with empty value for a BigDecimal/BigInteger JAXB throws NumberFormatException. For the case of BigDecimal it will be NumberFormatException at java.math.BigDecimal.<init> and for BigInteger it can be NumberFormatException: Zero length BigInteger at java.math.BigInteger.<init> exception. To overcome this problem, Jaxb provides a feature called TypeAdapters. Using TypeAdapters we can specify how to marshall/unmarshall a particular object or complex xml type when some of its fields are not proper. For example we can instruct JAXB if BigDecimal is empty treat it as 0, don't report an exception. BigDecimal Adapter Below is the sample BigDecimal Adapter which advices marshall and unmarshall in the event of null values. /* * * BigDecimalAdapter.java * Adapter for java.math.BigDecimal objects * */ pac