public static String truncate(String text,int truncatedLength){
  if (text == null) {
    return null;
  }
  if ((truncatedLength < 0) || (truncatedLength > text.length())) {
    return text;
  }
  return text.substring(0,truncatedLength);
}

public static String truncate ( String text , int truncatedLength ) { if ( text == null ) { return null ; } if ( ( truncatedLength < 0 ) || ( truncatedLength > text . length ( ) ) ) { return text ; } return text . substring ( 0 , truncatedLength ) ; }
truncate a string to a max length
