Skip to content

Instantly share code, notes, and snippets.

@rezaiyan
Last active March 30, 2018 20:06
Show Gist options
  • Save rezaiyan/061971d578df3c9835c4e78f11f30e59 to your computer and use it in GitHub Desktop.
Save rezaiyan/061971d578df3c9835c4e78f11f30e59 to your computer and use it in GitHub Desktop.
public static String formatPrice(double priceAsDouble) {
NumberFormat formatter = NumberFormat.getInstance();
if (Math.round(priceAsDouble * 100) % 100 == 0) {
formatter.setMaximumFractionDigits(0);
}
return formatter.format(priceAsDouble);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment