How to Convert 18 Digit Id to 15 Digit Id using Apex Class?
Example1:
convert the Id to a String and using substring(startIndex, endIndex) its possible to convert from 18 digit Id to 15 Digit Id.
String AccountId = String.valueOf(Account.Id).substring(0, 15);
Example2:
To convert it to 15 digits to 18 digits then you can simply set it to an Id type variable:
Id someId = ‘001J000001eun1Q’;
Which will automatically convert it for you:
system.debug(someId); // 001J000001eun1QIAQ
Then you can simply call the getSObjectType() method on the Id variable which will return the object name:
Schema.SObjectType objectType = someId.getSObjectType();
system.debug(objectType); // Account
Salesforce ID Converter
Converting 15 digit to 18 digit Salesforce ID
https://help.magentrix.com/aspx/ConvertSFID
What is the difference between a 15 digit and a 18 digit Salesforce ID?
A 15 digit Salesforce ID is case sensitive. Ex: 00570000001ZwTi and 00570000001ZWTI are different.
A 18 digit Salesforce ID is case in-sensitive. Ex: 00570000001ZwTiXYZ and 00570000001ZWTIXYZ are same.