Java DecimalFormat .setDecimalSeparatorAlwaysShown (boolean newValue)

Syntax

DecimalFormat.setDecimalSeparatorAlwaysShown(boolean newValue) has the following syntax.

public void setDecimalSeparatorAlwaysShown(boolean newValue)

Example

In the following code shows how to use DecimalFormat.setDecimalSeparatorAlwaysShown(boolean newValue) method.


import java.text.DecimalFormat;
//from w w  w.  j a  v  a2  s.co m
public class Main {
  public static void main(String[] argv) throws Exception {
    DecimalFormat format = new DecimalFormat();
    format.setDecimalSeparatorAlwaysShown(false);
    System.out.println(format.format(123456789.12345678));

  }
}

The code above generates the following result.





















Home »
  Java Tutorial »
    java.text »




DateFormat
DecimalFormat
NumberFormat
SimpleDateFormat