how to trim a string to a particular length in apex code example
Example: apex truncate string if it is longer
String sizeString = 'Let\'s Imagine this is more than 120 Characters';
Integer maxSize = 120;
if(sizeString.length() > maxSize ){
sizeString = sizeString.substring(0, maxSize);
}