B4J Question [Solved}numberformat problem

Peter Lewis

Active Member
Licensed User
Longtime User
Hi

I have a problem when doing totals on my page. This is the error

java.lang.NumberFormatException: For input string: "13,686.63"

I just saw now that this converts doubles to a string !!! AM I BAD !!!

My code is very simple and I have kept the variables as doubles all the way thru. If you can let me know your comments , I would appreciate it.

Thank you

B4X:
    Dim ttl As Double
    Dim ra As ResultSet
         ra= DB.Sql1.ExecQuery2("SELECT Ext_Price, USD_RAPP, InvNo FROM Invoice_footer WHERE InvNo = ? ", Array As String (NextInvNo))
   
    Do While ra.NextRow
  
     ttl = ttl + ra.GetDouble("USD_RAPP")
          
    Loop
  

    ttl=NumberFormat(ttl,0,2)
 
Last edited:

stevel05

Expert
Licensed User
Longtime User
A double will not accept the thousands separator i.e. the "," within the value.
 
Upvote 0

Peter Lewis

Active Member
Licensed User
Longtime User
A double will not accept the thousands separator i.e. the "," within the value.
I thought so but I did not put that , As you can see the code I specified ttl as double and I read everything as double but when it added up it put the comma !!

Maybe I should make a new variable xyz as String and use that in the Final format .
 
Upvote 0

stevel05

Expert
Licensed User
Longtime User
Numberformat2 also allows excluding the thousands separator (Grouping).
 
Upvote 0
Top