cancel
Showing results for 
Search instead for 
Did you mean: 

Simple Java Question - How to test if a given string is numeric or not

Former Member
0 Kudos

Hi Experts,

I have written one Java program. It fetches user ID from UME. The code is as below:


Iterator itr = role.getUserMembers(true);
while (itr.hasNext()) {
String uniqId = (String) itr.next();
IUser thisUser = myUserFactory.getUser(uniqId);
wdComponentAPI.getMessageManager().reportSuccess("here "+thisUser.getUid() );

Used ID is thisUser.getUid() . I have to find out all user IDs which are numeric.

Do we have any standard Java program (API) to find out whether thisUser.getUid() is numeric or not.

Regards,

Gary

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi

Just try to parse this string to integer or long number and catch the NumberFormatException.

Somthing like:

 
try
{
   Integer.parseInt(userIdString);
}
catch(NumberFormatException e)
{
  //do sume thing when user id is not number
}

good luck

Answers (0)