Skip to content

Instantly share code, notes, and snippets.

@fnzainal
Created January 24, 2017 14:32
Show Gist options
  • Save fnzainal/e1f92a79cfdc0378223c3a172012ee1e to your computer and use it in GitHub Desktop.
Save fnzainal/e1f92a79cfdc0378223c3a172012ee1e to your computer and use it in GitHub Desktop.
to make currency format
import java.text.DateFormat;
import java.text.DecimalFormat;
import java.text.DecimalFormatSymbols;
import java.text.SimpleDateFormat;
/**
* convert string to currency format
* @param value money
* @return
*/
String toCurrency(String s){
DecimalFormatSymbols symbols = new DecimalFormatSymbols();
symbols.setDecimalSeparator(',');
DecimalFormat decimalFormat = new DecimalFormat("###,###,###,###", symbols);
String currency = decimalFormat.format(Integer.parseInt(s));
return currency;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment