Java tutorial
//package com.java2s; //License from project: Apache License import java.text.DecimalFormat; public class Main { public static String getFormattedAmount(double amount) { try { String amountString = new DecimalFormat("#,###").format(amount); return amountString.replace(",", "."); } catch (NumberFormatException e) { return "" + amount; } catch (NullPointerException e) { return "" + amount; } } }