I have a rest api in java 8 with spring-boot and my service returns a json where it shows me my Double value with the letter E inside it (scientific notation). My value in the DB is stored without the letter E. When I retrieve it, it is already stored in my Double property with the letter E. How can I make the API response without the E in the value of the double???. I show you my answer class.
public class Empresa {
private String nombre;
private Double monto;
// getters y setters aca
}
and the response I see is:
{
"Empresa": {
"nombre": "Empresa1",
"monto": 4.23423443E8
}
}
I already found the drawback. I'm posting the answer in case someone has the same problem. The problem comes from the fact that Double has less precision than BigDecimal and that is where Doubles that have very large values add the letter E. What I did was manage from the time I get until the time I return, always with BigDecimal, which, although slower, is slower. safe and more accurate. Here I leave a link where it is explained in a little more detail what I am doing. Read: Why use BigDecimal (and not Double) for financial arithmetic calculations