To check if a value is a double value in Android you can use the snippet below.
Samples
Java (Android) Sample
1 2 3 4 5 6 7 8 |
public static boolean IsDoubleValue(String input) { if(!TextUtils.isEmpty(input.trim())) { //use <em>if(!input.trim().toString().equals("")) {</em> if you are not on the Android platform String regExp = "[\\x00-\\x20]*[+-]?(((((\\p{Digit}+)(\\.)?((\\p{Digit}+)?)([eE][+-]?(\\p{Digit}+))?)|(\\.((\\p{Digit}+))([eE][+-]?(\\p{Digit}+))?)|(((0[xX](\\p{XDigit}+)(\\.)?)|(0[xX](\\p{XDigit}+)?(\\.)(\\p{XDigit}+)))[pP][+-]?(\\p{Digit}+)))[fFdD]?))[\\x00-\\x20]*"; return input.matches(regExp); }else{ return false; } } |
If you have any questions or suggestions feel free to rate this snippet, post a comment or Contact Us via Email.
Related links: