February 19, 2012

Formatting and converting data in Java

If you need to format dates and numbers into a locale-sensitive string or if you just need to convert data between different types then take a look at psdi.util.MaxType class.
For example, the following piece of code shows how to correctly format a currency amount into a string.
MaxType mt = new MaxType(MaxType.AMOUNT);
mt.setValue(10.1234);
String s = mt.asLocaleString();

0 comments:

Post a Comment