on 04-20-2010 7:37 AM
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
Hello!
Try to change your pattern to this one
Locale mylocale = Locale.GERMAN;
String pattern = "#,#00.00";
NumberFormat nf = NumberFormat.getNumberInstance(mylocale);
DecimalFormat df = (DecimalFormat)nf;
df.applyPattern(pattern);
String output = df.format(1111111.222);
Pattern has an influence on number of digits between separators, but you have to use ',' for grouping and '.' for decimal. Character values for separators correspond to your Locale object.
Thanks, Mikhail
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
84 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.