Wile developing an application in SAP NWDS. I got this requirement once, like:
Problem :
There is a String having UserId concatenated with User name followed by '-'. (00001234 - Test Sap, 00000102 - Test1 sap, 00000002 - Test2 sap) .
The requirement was to get just no. 1234, 102, 2 respectively.
Solution:
- Split the string followed by space into parts using:
String pernr = "00001234 - Test Sap";
String[] tokens = "this is a test".split("\\s"); - Take the substring
tokens[0] and parse it to Integer.
int result = Integer.parseInt(tokens[0]); - You will get the required value in result.
result will have value = 1234 .
No comments:
Post a Comment