본문 바로가기

Java

[JAVA] DecimalFormat

import java.text.DecimalFormat;
import java.util.GregorianCalendar;

public class TestDecimal {

   public static void main(String[] args) throws Exception {

    DecimalFormat money = new DecimalFormat("#,#00");

    double amount = 444444444.444444444;

   System.out.println("txtValidFlag : " + money.format(amount));
   }
}

-> 444,444,444

    DecimalFormat money = new DecimalFormat("#,#00"); 를
    DecimalFormat money = new DecimalFormat("#,#00.000"); 으로 하면

-> 444,444,444.444