yes of course I know!
But how can I be sure that this String is a Integer ?
I mean I can simply convert this String to an Integer,
but I doubt this would help, cause a String can get converted to an
Integer.
(Like A is 65 I think)
So how can I be sure that the user typed 65 and not A ?
Marcus
Check out the static methods of the java.lang.Character class. isDigit()
should solve your dilemma.
Mark
-Original Message-
From: Marcus Biel [mailto:Marcus.Biel;bmw.de]
Sent: Thursday, October 31, 2002 7:04 AM
yes of course I know!
But how can I be sure that this String is a Integer ?
What is a 'good-practice' method of validating a numeric string?
Ive been lazy and am doing a Integer.parseInt() in a try catch but its
probably far from the best way...
(Have been meaning to check out the java.text.NumberFormat stuff but always
had more interes... uh... important things to do
Well, Marcus was just asking how he could differentiate between an input of
A vs 65 (text vs digit). The simplest way I know is something like:
char test = request( getParameter( formObject1 )).charAt( 0 );
if( Character.isDigit( test ) {
doSomething();
}
If you want to validate the accuracy
But remember we got Strings, not Characters.
Sorry I know this is dumb, but today I worked this much,
I really can't get a clear mind.
8-)
marcus
[EMAIL PROTECTED] schrieb:
Check out the static methods of the java.lang.Character class. isDigit()
should solve your dilemma.
Mark
--
To
See my response to Andrew for taking a String and getting a char out of it -
posted about an hour ago.
Mark
-Original Message-
From: Marcus Biel [mailto:Marcus.Biel;bmw.de]
Sent: Thursday, October 31, 2002 8:27 AM
To: [EMAIL PROTECTED]
Subject: Re: MVC Design: property in ActionForm or
hehe, I know the feeling :-)
-Original Message-
From: Marcus Biel [mailto:Marcus.Biel;bmw.de]
Sent: Thursday, October 31, 2002 21:27
To: [EMAIL PROTECTED]
Subject: Re: MVC Design: property in ActionForm or Bean with property in
A ctionForm ?
But remember we got Strings, not Characters.
7 matches
Mail list logo