Several decimal for double in JAXB
The simplest way is this
double taxFreeValue;
@XmlElement(name = "TaxFree")
private String getTaxFree() {
return String.format("%.3f", taxFreeValue);
}
Note that you can give this method any name and make it private JAXB dont care as soon as the annotation is present.
You can use an XmlAdapter
to convert from the double value to the desired text (String) representation.
- Using JAXB generated class for an element that requires an integer with a pattern