Created
March 15, 2023 12:00
Fix decimal format for price
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static String getDecimalFormat(double value) { | |
String newValue = new DecimalFormat("#.##").format(value); | |
if (!newValue.contains(".")) { | |
return newValue + ".00"; | |
} else { | |
return newValue.split("\\.")[1].length() == 1 ? (newValue + "0") : newValue; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment