You need to sign in to do that
Don't have an account?
Newby
substring in apex code
Hi All,
I want to get first two characters from first name and first 2 characters from the last name and then concatenate and save the result of it in the nick name in apex code while creating the user.
Can someone please help me with the code.
Thanks
you can use,
String concat = FirstName.substring(0,2) + LastName.substring(0,2);
public static Date ParsedDate (String DateString) {
String values;
String month;
String year;
String day;
for(integer i = 0; i < DateString.length(); i++) {
if(i<4) {
year = DateString.substring(0,4);
}
if(i>=4 && i<=5) {
month = DateString.substring(4,6);
}
if(i>=6 && i<=7) {
day = DateString.substring(6,8);
}
}
Date mydate = Date.newInstance(integer.valueOf(year),integer.valueOf(month),integer.valueOf(day));
return mydate;
}
}
Use this string method to convert yyyymmdd format to date.Use this code it helps.