Created
January 24, 2017 14:32
-
-
Save fnzainal/e1f92a79cfdc0378223c3a172012ee1e to your computer and use it in GitHub Desktop.
to make currency format
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
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