Java:
package com.xieh; import java.text.DecimalFormat; public class MoneyFormat { public static void main(String args[]) { double n = 2000000.1458; DecimalFormat df = new DecimalFormat("#,###.00"); String m = df.format(n); System.out.print(m); } }
JavaScript: