Problem

A company that utilizes salesforce to store customer details has a requirement to develop an apex method to convert 18 characters ids to 15 characters. This is to integrate with their on-premise system to synchronize records. The on-premise system has a limitation that it can accept identifiers with 15 characters.


To address this limitation, the salesforce team has opted to develop an apex utility method. This method is responsible to convert the record Ids from 18 characters to 15 characters to comply with the external system's requirements.


Complete the following apex code to return a 15 digits id for a given input of 18 digit ids.


Instructions:


1. The apex method must accept an id parameter

2. The Id parameter can either be 18 or 15 characters

3. Convert only 18 characters ids to 15 characters


Example:

Id recordId = '0015h00001e70eLAAQ';

String converetedId = ApexIdUtility.converIdTo15Chars(recordId);

The 15 character id is 0015h00001e70eL


Note: The record is a unique identifier for salesforce records. The record id’s are generated once records are successfully inserted into the database. The apex provides a predefined set of methods for Id’s. Visit the apex developers guide here to know more about the id class methods in apex.