Java DecimalFormat format decimal to String like "$123,456.79" add dollar sign

Description

Java DecimalFormat format decimal to String like "$123,456.79" add dollar sign

import java.text.DecimalFormat;

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



PreviousNext

Related