OVH Cloud OVH Cloud

Convertir String en bigdecimal

2 réponses
Avatar
Informatique CARPIMKO
Bonjour,
quasiment tout est dit dans le titre.
Je récupère une variable avec request.getParameter("var");
et je veux la transformer en BigDecimal.
Certaines classes comme int, long... on des méthodes pour le faire (int i =
Integer.parseInt("var");)mais pas BigDecimal.
Quel est le meilleur moyen ?
Merci

2 réponses

Avatar
damien guerin
ça marche pas ça ?
new BigDecimal("var");
Avatar
Simon OUALID
Informatique CARPIMKO wrote:
Quel est le meilleur moyen ?


public BigDecimal(String val) ?
http://java.sun.com/j2se/1.5.0/docs/api/java/math/BigDecimal.html#BigDecimal(java.lang.String)

--

String maString = req.getParameter("toto");
BigDecimal b = new BigDecimal(maString);

--

Symon