number-formatting

Invalid double in converting String to Double

天大地大妈咪最大 提交于 2019-12-02 17:15:04
问题 i get a NumberFormatException : invalid double "111,000,000" in this line of code : double SalePotential = Double.valueOf(EtPotential.getText().toString()); in the beginning i've used Numberformat , to format my double value for separating number and inserted it to an EditText but when i try to retrieve the value of EditText it throws me the exception : NumberFormat f = NumberFormat.getInstance(); EtPotential.setText(String.valueOf(f.format(PTData.SalePotential))); i've also tried

Caused by: java.lang.NumberFormatException: Invalid double: “” with blank value

♀尐吖头ヾ 提交于 2019-12-02 17:02:25
问题 I get ther error when JSON string have some blank value, getting from server, how to deal with blank values here is JSON { "status":"success", "data":[ { "id":"1", "name":"ABC", "address":"ABC, QWE", "lat":"16.799999", "lng":"96.150002", "admin_id":"4", "is_approved":"1", "added":"2015-08-07 11:17:12", "status":"1", "image_file":"", "image_width":"", "image_height":"" } ] } Gson gson = new GsonBuilder().serializeNulls().create(); Type listType = new TypeToken<List<MyData>>() {}.getType();

How to format gridview columns?

百般思念 提交于 2019-12-02 15:13:31
问题 Below is my code: var grid = new GridView(); grid.DataSource = myDataset; grid.DataBind(); I want to format some of the columns of my grid to Currency with thousand separator and with decimal like '$9,999,999.99'. I am exporting the grid to excel and I want to see the values in currency format. I am creating gridview during runtime. I have no html code for my gridview. I am just bounding dataset to gridview and exporting to excel. I won't see gridview in HTML format. How to do that? 回答1:

iOS swift NumberFormatter decimal style localization

落爺英雄遲暮 提交于 2019-12-02 12:28:25
问题 I am working with NumberFormatter.Style.decimal I need 20000.23 should be 20,000.23 for that I create an extension var NumerWithDecimalPoint : String{ if self != ""{ let numberFormatter = NumberFormatter() if IS_PERSIAN{ numberFormatter.locale = Locale(identifier: "fa_IR") }else{ numberFormatter.locale = Locale(identifier: "EN") } numberFormatter.numberStyle = NumberFormatter.Style.decimal numberFormatter.maximumFractionDigits = 2 numberFormatter.roundingMode = .floor let number =

Caused by: java.lang.NumberFormatException: Invalid double: “” with blank value

六月ゝ 毕业季﹏ 提交于 2019-12-02 10:05:21
I get ther error when JSON string have some blank value, getting from server, how to deal with blank values here is JSON { "status":"success", "data":[ { "id":"1", "name":"ABC", "address":"ABC, QWE", "lat":"16.799999", "lng":"96.150002", "admin_id":"4", "is_approved":"1", "added":"2015-08-07 11:17:12", "status":"1", "image_file":"", "image_width":"", "image_height":"" } ] } Gson gson = new GsonBuilder().serializeNulls().create(); Type listType = new TypeToken<List<MyData>>() {}.getType(); myDataArrayList = gson.fromJson(response.getString("data"), listType); In MyData class I tried to change

Invalid double in converting String to Double

谁都会走 提交于 2019-12-02 09:50:29
i get a NumberFormatException : invalid double "111,000,000" in this line of code : double SalePotential = Double.valueOf(EtPotential.getText().toString()); in the beginning i've used Numberformat , to format my double value for separating number and inserted it to an EditText but when i try to retrieve the value of EditText it throws me the exception : NumberFormat f = NumberFormat.getInstance(); EtPotential.setText(String.valueOf(f.format(PTData.SalePotential))); i've also tried DecimalFormat or Double.parseDouble with no Success. any help would be Appreciated! : DecimalFormat f = new

How to convert Decimal to String with two digits after separator?

﹥>﹥吖頭↗ 提交于 2019-12-02 08:44:38
问题 This is what I do now: extension Decimal { var formattedAmount: String { let formatter = NumberFormatter() formatter.generatesDecimalNumbers = true formatter.minimumFractionDigits = 2 formatter.maximumFractionDigits = 2 return formatter.string(from: self) //mismatch type } } but I cannot create NSNumber from Decimal . 回答1: This should work extension Decimal { var formattedAmount: String? { let formatter = NumberFormatter() formatter.generatesDecimalNumbers = true formatter

PHP - number_format and rounding

谁都会走 提交于 2019-12-02 08:07:01
The number_format function in PHP seems to round by default. My understanding is that this function is useful for separating every three numbers with a comma. Like 1403423 becomes 1,404,423 when using number_format. So, if I have a large number that I want rounded to two decimal places, how can I do this and still have the commas properly displayed? Desired behavior: 12042.529 --> 12,042.53 $a=12042.529; echo number_format($a,2,'.',','); 来源: https://stackoverflow.com/questions/19019409/php-number-format-and-rounding

Convert decimal separator from ',' (comma) to '.' (dot) e.g. “7,5” to “7.5”

邮差的信 提交于 2019-12-02 05:58:53
Yes. I know. Those are localization settings... But I wont tell my client to change localization settings for just my app. So how to convert those numbers? Or how to change number formatting for given range. (Need dots there, user may input comas or dots, or even numbers where commas just separate like 1,000,000.00 ...) EDIT: Circumvented whole issue by CStr(), and passing on the strings. If this is purely for display purposes then you can use custom format strings on the cells. Then your users can continue to use their localization settings that they are used to for inputting numbers. I think

Cross Platform Support for sprintf's Format '-Flag

試著忘記壹切 提交于 2019-12-02 04:13:32
The Single UNIX Specification Version 2 specifies the sprintf 's format ' -flag behavior as: The integer portion of the result of a decimal conversion ( %i , %d , %u , %f , %g or %G ) will be formatted with thousands' grouping characters [ 1 ] I can't find the format ' -flag in the c or the c++ specifications. g++ even warns : ISO C++11 does not support the ' printf flag The flag is not recognized to even warn about in Visual C; printf("%'d", foo) outputs : 'd I'd like to be able to write C-standard compliant code that uses the behavior of the format ' -flag. Thus the answer I'm looking for