Java DecimalFormat format decimal to String like "123,456.789" with comma

Description

Java DecimalFormat format decimal to String like "123,456.789" with comma

import java.text.DecimalFormat;

public class Main {
  public static void main(String[] args) throws Exception {
    DecimalFormat myFormatter = new DecimalFormat("###,###.###");
    String output = myFormatter.format(123456.789);
    System.out.println(output);//from   www  .ja  v  a 2  s .c o m
  }
}



PreviousNext

Related