I retrieve REAL value from SQLite database as String and then convert this value to Double. And I would like to use DecimalFormat object to format this value. My problem is presented below:
This sample code works(2.2 -> 2.20):
DecimalFormat df = new DecimalFormat("0.00");
Double value = new Double(2.2);
String result = df.format(value);
But this code that I use doesn't work(2.2 -> 2.2):
DecimalFormat df = new DecimalFormat("0.00");
Double sellPrice = Double.parseDouble(sellEntity.getSellPrice());
String result = df.format(sellPrice);
What I'm doing wrong. What is the reason of that and how it can be resolved?
Aucun commentaire:
Enregistrer un commentaire