I have String like this ""3333""
I want convert to Long
but when convert I am seeing this Exception
java.lang.NumberFormatException
I try many ways but I cant convert
I am trying this way
public void addNewFriend(List<String> mobileList, String login) {
try {
List<Long> list = new ArrayList<>();
mobileList.forEach(x -> {
log.debug(x);
x=x.replace("\\\"","");
Long y = Long.parseLong(x);
log.debug(y.toString());
list.add(y);
});
log.debug(list.toString());
Set<AppUser> appUsers = appUserRepository.findByMobileNumberIn(list);
if (appUsers.size() > 0) {
AppUser appUser = appUserRepository.findByLogin(login);
appUser.friends(appUsers);
appUserRepository.save(appUser);
} else {
throw new BadRequestAlertException("cannot find user relation with author", "AppUser", "List is Empty");
}
} catch (NoSuchElementException e) {
throw new BadRequestAlertException("Cannot find User", "Url", "Check your input");
} catch (NullPointerException e) {
throw new BadRequestAlertException("cannot find user relation with author", "AppUser", "List is Empty");
} catch (Exception e) {
throw new BadRequestAlertException(e.getMessage(), "Server Error", "Check it!");
}
}
note: I am take this request from kafka I can't get mobile list in long direct