How to suppress final 0 with DecimalFormat?

From: Adam Lipscombe (adam.lipscombe_at_qucs.co.uk)
Date: 11/29/04


Date: Mon, 29 Nov 2004 13:42:37 -0000


 Folks,

I need to output a blank if a double is 0.0;

If I use DecimalFormat to format a zero double I get a single "0" output.
i.e.

                double d = 0.0;
                DecimalFormat dF = new DecimalFormat("#.##");
                System.out.println(dF.format(d));

gives "0".

How do I get rid of the zero?

TIA -Adam



Relevant Pages

  • Prevent Blank Records being written. Need Help.
    ... Secondary record format is as follows: ... character text field, ... no input mask requirement ... allow zero length = yes. ...
    (microsoft.public.access.forms)
  • RE: Prevent Blank Records being written. Need Help.
    ... Secondary record format is as follows: ... > no input mask requirement ... > 30 character text field, ... > allow zero length = yes. ...
    (microsoft.public.access.forms)
  • Re: zero values in bar chart
    ... If column or bar, what did you want - how do you want to plot ... If zero always means zero, then you should definitely trust your ... Create a second column data series, with the values of N or 0 as ... above, then format the series with the pale fill, or no fill. ...
    (microsoft.public.excel.charting)
  • RE: Formatting a Spreadsheet
    ... There's a checkbox under Tools, Options, on the View tab, by which you ... can control IN GENERAL the display of zero values. ... in my experience it won't be long before you need some cells to ... Select the cellwhose display format you want to change. ...
    (microsoft.public.excel.misc)
  • Re: Number+1
    ... I had to add a (between CDbl and Format and drop one of the 0's from "Format ... Text String portion. ... using the BeforeInsert event means that the code will only run when a new ... post is 7110001 - no leading zero. ...
    (microsoft.public.access.gettingstarted)