|
Attention! Read the forum rules carefully before posting a topic.
Try to find an answer in Wiki before asking a question. Submit programming questions in this forum only. Off topics are strictly forbidden.
Any topics which do not satisfy these rules will be deleted.
| Detect type of message, string or double |
|
jaime_1008
|
| Post subject: Detect type of message, string or double |
Post rating: 0
|
Posted: Fri 10 May, 2013, 15:46
|
|
User rating: 1
Joined: Sun 18 Dec, 2011, 04:05 Posts: 36 Location: Spain, Madrid
|
|
Hi,
I expect to recive double data from IMessage, but sometimes also recive String message. the question is: -How to detect if the data is a string or double?, and if is a string, how to convert to double?
example: if recive 7,2% (string), how to convert to double 7,2.
NOTE: the error that display is: java.lang.NumberFormatException : For input string:"7,2%"
Thank you
|
|
|
|
|
 |
|
API Support
|
| Post subject: Re: Detect type of message, string or double |
Post rating: 1
|
Posted: Fri 10 May, 2013, 16:24
|
|
User rating: ∞
Joined: Fri 31 Aug, 2007, 09:17 Posts: 6139
|
It is not advised to rely on message string contents as they are subject to change, hence in such case you will need to rewrite your strategy. However, if you still want to do it, you need to use string and double operations like:
|
|
|
|
|
 |
|
jaime_1008
|
| Post subject: Re: Detect type of message, string or double |
Post rating: 0
|
Posted: Fri 10 May, 2013, 16:43
|
|
User rating: 1
Joined: Sun 18 Dec, 2011, 04:05 Posts: 36 Location: Spain, Madrid
|
|
|
|
|
 |
|
jaime_1008
|
| Post subject: Re: Detect type of message, string or double |
Post rating: 0
|
Posted: Fri 10 May, 2013, 20:59
|
|
User rating: 1
Joined: Sun 18 Dec, 2011, 04:05 Posts: 36 Location: Spain, Madrid
|
|
Fix it.
using str.replace("","") and then convert to double
thank you
|
|
|
|
|
 |
|
Pages: [
1
]
|
|
|
|
|