If you want to format decimal numbers, you can use DecimalFormat class to do this. DecimalFormat is a concrete subclass of NumberFormat that formats decimal numbers. It has a variety of features designed to make it possible to parse and format numbers in any locale, including support for Western, Arabic, and Indic digits. It also supports different kinds of numbers, including integers (123), fixed-point numbers (123.4), scientific notation (1.23E4), percentages (12%), and currency amounts ($123). All of these can be localized.

The following example shows how to do this:

 import java.text.*;

public class number {

  public static void main(String args[]) {

    double d = 123456.78;
    DecimalFormat df = new DecimalFormat("#####0.00");