<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: How to check if String is parseable to Integer or Double?</title>
	<atom:link href="http://www.javablogging.com/how-to-check-if-string-is-parseable-to-integer-or-double/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.javablogging.com/how-to-check-if-string-is-parseable-to-integer-or-double/</link>
	<description>Tracking surprises, features and bugs</description>
	<lastBuildDate>Wed, 21 Jul 2010 14:19:17 -0500</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: mithrandir</title>
		<link>http://www.javablogging.com/how-to-check-if-string-is-parseable-to-integer-or-double/comment-page-1/#comment-1618</link>
		<dc:creator>mithrandir</dc:creator>
		<pubDate>Wed, 03 Feb 2010 14:40:55 +0000</pubDate>
		<guid isPermaLink="false">http://www.javablogging.com/?p=810#comment-1618</guid>
		<description>Also - if you already know that your data is a valid double but you want to store something like 1.00000 as an Integer you could simply use:

double do = Double.parseDouble(myData);
if(do % 1 == 0)
{
     int i = (int) do;
}</description>
		<content:encoded><![CDATA[<p>Also &#8211; if you already know that your data is a valid double but you want to store something like 1.00000 as an Integer you could simply use:</p>
<p>double do = Double.parseDouble(myData);<br />
if(do % 1 == 0)<br />
{<br />
     int i = (int) do;<br />
}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: sevencardz</title>
		<link>http://www.javablogging.com/how-to-check-if-string-is-parseable-to-integer-or-double/comment-page-1/#comment-1504</link>
		<dc:creator>sevencardz</dc:creator>
		<pubDate>Fri, 15 Jan 2010 22:32:11 +0000</pubDate>
		<guid isPermaLink="false">http://www.javablogging.com/?p=810#comment-1504</guid>
		<description>If you are validating a String that might not be a number, write a for() loop and use Character.isDigit(char) before converting the String to a double.  Then use the method above.  Be sure to add a condition for numbers in scientific notation.</description>
		<content:encoded><![CDATA[<p>If you are validating a String that might not be a number, write a for() loop and use Character.isDigit(char) before converting the String to a double.  Then use the method above.  Be sure to add a condition for numbers in scientific notation.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: sevencardz</title>
		<link>http://www.javablogging.com/how-to-check-if-string-is-parseable-to-integer-or-double/comment-page-1/#comment-1503</link>
		<dc:creator>sevencardz</dc:creator>
		<pubDate>Fri, 15 Jan 2010 22:23:22 +0000</pubDate>
		<guid isPermaLink="false">http://www.javablogging.com/?p=810#comment-1503</guid>
		<description>public static boolean isInt(double value) {
    return Math.floor(value) == value;
}</description>
		<content:encoded><![CDATA[<p>public static boolean isInt(double value) {<br />
    return Math.floor(value) == value;<br />
}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Rastislav</title>
		<link>http://www.javablogging.com/how-to-check-if-string-is-parseable-to-integer-or-double/comment-page-1/#comment-1162</link>
		<dc:creator>Rastislav</dc:creator>
		<pubDate>Wed, 25 Nov 2009 10:51:24 +0000</pubDate>
		<guid isPermaLink="false">http://www.javablogging.com/?p=810#comment-1162</guid>
		<description>You can use DecimalFormatSymbols to improve regexp to better match locale settings.

DecimalFormatSymbols dfs = DecimalFormatSymbols.getInstance(Locale.getDefault());
        dfs.getDecimalSeparator();
        dfs.getExponentSeparator();
        dfs.getGroupingSeparator();</description>
		<content:encoded><![CDATA[<p>You can use DecimalFormatSymbols to improve regexp to better match locale settings.</p>
<p>DecimalFormatSymbols dfs = DecimalFormatSymbols.getInstance(Locale.getDefault());<br />
        dfs.getDecimalSeparator();<br />
        dfs.getExponentSeparator();<br />
        dfs.getGroupingSeparator();</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: alberlau</title>
		<link>http://www.javablogging.com/how-to-check-if-string-is-parseable-to-integer-or-double/comment-page-1/#comment-1003</link>
		<dc:creator>alberlau</dc:creator>
		<pubDate>Fri, 13 Nov 2009 11:30:11 +0000</pubDate>
		<guid isPermaLink="false">http://www.javablogging.com/?p=810#comment-1003</guid>
		<description>Why not use: org.apache.commons.lang.math.NumberUtils.isDigit(String number) or isNumber? I like apache.commons and I&#039;m use them extensively. 

Checks whether the String a valid Java number.
Valid numbers include hexadecimal marked with the 0x qualifier, scientific notation and numbers marked with a type qualifier (e.g. 123L).
Null and empty String will return false.</description>
		<content:encoded><![CDATA[<p>Why not use: org.apache.commons.lang.math.NumberUtils.isDigit(String number) or isNumber? I like apache.commons and I&#8217;m use them extensively. </p>
<p>Checks whether the String a valid Java number.<br />
Valid numbers include hexadecimal marked with the 0x qualifier, scientific notation and numbers marked with a type qualifier (e.g. 123L).<br />
Null and empty String will return false.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Trollhorn</title>
		<link>http://www.javablogging.com/how-to-check-if-string-is-parseable-to-integer-or-double/comment-page-1/#comment-997</link>
		<dc:creator>Trollhorn</dc:creator>
		<pubDate>Fri, 13 Nov 2009 10:06:50 +0000</pubDate>
		<guid isPermaLink="false">http://www.javablogging.com/?p=810#comment-997</guid>
		<description>Well, data validation in general is quite hard and often done wrong... I think the best idea is to use some sort of validation framework...</description>
		<content:encoded><![CDATA[<p>Well, data validation in general is quite hard and often done wrong&#8230; I think the best idea is to use some sort of validation framework&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Joe Darcy</title>
		<link>http://www.javablogging.com/how-to-check-if-string-is-parseable-to-integer-or-double/comment-page-1/#comment-993</link>
		<dc:creator>Joe Darcy</dc:creator>
		<pubDate>Thu, 12 Nov 2009 22:15:42 +0000</pubDate>
		<guid isPermaLink="false">http://www.javablogging.com/?p=810#comment-993</guid>
		<description>The javadoc comment for Double.valueOf(String):
http://java.sun.com/javase/6/docs/api/java/lang/Double.html#valueOf(java.lang.String)
includes a regular expression that recognizes valid inputs.</description>
		<content:encoded><![CDATA[<p>The javadoc comment for Double.valueOf(String):<br />
<a href="http://java.sun.com/javase/6/docs/api/java/lang/Double.html#valueOf(java.lang.String)" rel="nofollow">http://java.sun.com/javase/6/docs/api/java/lang/Double.html#valueOf(java.lang.String)</a><br />
includes a regular expression that recognizes valid inputs.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tweets that mention JavaBlogging » How to check if String is parseable to Integer or Double? -- Topsy.com</title>
		<link>http://www.javablogging.com/how-to-check-if-string-is-parseable-to-integer-or-double/comment-page-1/#comment-990</link>
		<dc:creator>Tweets that mention JavaBlogging » How to check if String is parseable to Integer or Double? -- Topsy.com</dc:creator>
		<pubDate>Thu, 12 Nov 2009 19:56:47 +0000</pubDate>
		<guid isPermaLink="false">http://www.javablogging.com/?p=810#comment-990</guid>
		<description>[...] This post was mentioned on Twitter by bubbl. bubbl said: How to check if String is parseable to Integer or Double? http://ff.im/-blm4r [...]</description>
		<content:encoded><![CDATA[<p>[...] This post was mentioned on Twitter by bubbl. bubbl said: How to check if String is parseable to Integer or Double? <a href="http://ff.im/-blm4r" rel="nofollow">http://ff.im/-blm4r</a> [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dan Howard</title>
		<link>http://www.javablogging.com/how-to-check-if-string-is-parseable-to-integer-or-double/comment-page-1/#comment-987</link>
		<dc:creator>Dan Howard</dc:creator>
		<pubDate>Thu, 12 Nov 2009 17:40:15 +0000</pubDate>
		<guid isPermaLink="false">http://www.javablogging.com/?p=810#comment-987</guid>
		<description>The real issue IMO is that NumberFormatException is useless. 99% of the time you really will just treat a non parsable int as 0.

A try/catch is really not that expensive though.</description>
		<content:encoded><![CDATA[<p>The real issue IMO is that NumberFormatException is useless. 99% of the time you really will just treat a non parsable int as 0.</p>
<p>A try/catch is really not that expensive though.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Björn</title>
		<link>http://www.javablogging.com/how-to-check-if-string-is-parseable-to-integer-or-double/comment-page-1/#comment-978</link>
		<dc:creator>Björn</dc:creator>
		<pubDate>Thu, 12 Nov 2009 10:26:02 +0000</pubDate>
		<guid isPermaLink="false">http://www.javablogging.com/?p=810#comment-978</guid>
		<description>To achieve a total match with NumberFormat you have to evaluate your own ParsePosition object.

String input = &quot;2,33abc&quot;;
ParsePosition pp = new ParsePosition(0);
Number parsedNumber = NUMBERFORMAT.parse(input, pp);

if (input.length() == pp.getIndex()
    &amp;&amp; parsedNumber != null {
  // complete number was parsed
}</description>
		<content:encoded><![CDATA[<p>To achieve a total match with NumberFormat you have to evaluate your own ParsePosition object.</p>
<p>String input = &#8220;2,33abc&#8221;;<br />
ParsePosition pp = new ParsePosition(0);<br />
Number parsedNumber = NUMBERFORMAT.parse(input, pp);</p>
<p>if (input.length() == pp.getIndex()<br />
    &amp;&amp; parsedNumber != null {<br />
  // complete number was parsed<br />
}</p>
]]></content:encoded>
	</item>
</channel>
</rss>
