Top "Decimalformat" questions

The Java class DecimalFormat is a concrete subclass of NumberFormat that is used to format decimal numbers.

DecimalFormat pattern

public static String formatAmountUpToTwoDecimalNumber(String amount) { if(amount==null || "".equals(amount)) { return ""; } Double doubleAmount = Double.valueOf(amount); double myAmount = doubleAmount.…

java decimalformat
How to always show decimal part when using DecimalFormat?

Float sum = new Float(300); // always somehow calculated DecimalFormat df = new DecimalFormat("#.#"); String s = df.format(sum/3); // prints 100, I want 100.0 s = …

java decimalformat
Rounding with DecimalFormat in Java

Let's look at the following statements in Java. System.out.println(new DecimalFormat("0").format(2.4)); //returns 2 System.out.println(new DecimalFormat("0").…

java decimalformat
How to deserialize a float value with a localized decimal separator with Jackson

The input stream I am parsing with Jackson contains latitude and longitude values such as here: { "name": "product 23", "latitude": "52,48264", "longitude": "13,31822" } …

java jackson json-deserialization decimalformat formatexception
Java - always keep two decimal places even in zeroes

I am trying to keep two decimal places, even if then numbers are zeroes, using DecimalFormatter: DecimalFormat df = new DecimalFormat("#.00"); …

java decimalformat
Summing numbers with comma as decimal separator in XSLT?

I have an XML file where the number are comma-separated <foo> <bar val="1,23"/> <bar val="4,56"/&…

xml xslt sum decimalformat
What is the difference between #.## and ##.## pattern in Decimal Format?

In my program I'm using the pattern #.## in DecimalFormat as shown below: DecimalFormat df = new DecimalFormat("#.##"); By mistake I added …

java decimalformat
Java. How to disable rounding in DecimalFormat

Can I disable rounding "feature" in DecimalFormat? For example: DecimalFormat f = new DecimalFormat(); f.parseObject("123456789012345.99"); Result is 1.2345678901234598E14 java version "1.6.0_21"

java rounding decimalformat
What is the c# equivalent of Java DecimalFormat?

How would I convert the following code to C# DecimalFormat form String pattern = ""; for (int i = 0; i < nPlaces - …

c# java decimalformat