Skip to Content
0
Former Member
Apr 20, 2010 at 06:37 AM

Convert a String to Decimal Format in European format

347 Views

Hi Experts,

I am having a string as a context type for a input field, where the user can enter the Price, I need to convert the same into European format "###.###,00", I am using this below code to convert the string to decimal format

User will enter the input as 10 as it needs to be converted into 10,00. Also, 1000 which has to be converted as 1.000,00

String Str1 = wdContext.currentvn_temptable.getVa_TempUnitPrice();
Locale mylocale  = Locale.GERMAN;
String pattern="###.###,00";				
NumberFormat nf = NumberFormat.getNumberInstance(mylocale);
DecimalFormat df = (DecimalFormat)nf;
df.applyPattern(pattern);
String output = df.format(Str1);
wdComponentAPI.getMessageManager().reportSuccess("Unit Price" + " " + pattern + " " + output);

When I execute the above code, i am getting an error called "Malformed Pattern ###.###,00"

Please let me know, how to convert a String to Quantity in European format

Thanks & Regards,

Palani