Java provides a good way to format currencies using basic characters depending on a specific locale. For example, if this currency is the US dollar, you can reach $0.35either USD0.35for the US and UK locales, respectively. It is very good.
However, in some cases it is necessary to format the money in another, I would say, a more user-friendly style using small currency symbols. For example, 35¢or 35cinstead of the above examples. Wikipedia also says :
Cent is from 1 cent to 99 cents can be represented as one or two digits, followed by a corresponding reduction (2 ¢, 5 ¢, 75 ¢, 99 ¢)
However, I cannot find a way to format money amounts in this style using the JDK. I already tried to play with DecimalFormatSymbols, but this only allows you to configure the main currency symbol, so it DecimalFormatstill uses the original format, giving something like ¢35what is wrong. In addition, the custom format string for order correction may not be the language / language / agent of the country (intermediate space? Prefix or suffix notation?). Joda Money and its MoneyFormatter do not seem to have this feature either.
Is there a good way to format currency amounts using small currency symbols? Thanks in advance.
PS I'm not sure that the words "major" and "minor" are appropriate here.
source
share