Is it possible to parse the buggy from textfield? I have seen some code where they parse BigDecamal from strings. But is it possible to use it on the textfield? I have prepared some code for this work but I do not know that I should do it like this.
Float value = float.parseflat (textFieldInvoiceServicePrice.getText ()); String servicetext = textFieldInvoiceService.getText (); BigDicall PricexL = Value Value of Value (value);
No, this is not how you should do it - you currently have one Parsing the string to float, then change that float to BigDecimal
. You obviously know how to get a string from a text field, because you are already doing it in the first line - you can do this with BigDecimal
instead:
BigDCom Price = New BigDecimal (TextField invoice usage (Gettext));
However, you should be careful that it will not be culture-sensitive - it will always use .
as a decimal separator, for example. If you want culture-sensitive parsing, you should use the NumberFormat
.
No comments:
Post a Comment