You need to sign in to do that
Don't have an account?
Vijay Nagarathinam
Format SSN number with dashes
Hi All,
I want to format the SSN number with dashes. By default, it will without dashes.
Example : SSN = 1234567891
I want to convert into this format using apex 123-45-7891
Please let me know how to achieve this.
Thanks,
Vijay
I want to format the SSN number with dashes. By default, it will without dashes.
Example : SSN = 1234567891
I want to convert into this format using apex 123-45-7891
Please let me know how to achieve this.
Thanks,
Vijay
I like the above answer from Eric, here is one more way to do this
String ssn = '222552222';
String s1;
String s2;
String s3;
if (ssn != null) {
s1 = ssn.left(3);
s2 = ssn.right(6);
s3 = s2.left(2);
ssn = s1 + '-' + s3 + '-' + s2.right(4);
System.debug('************' + ssn);
}