code: public static String trimTrailingCharacter(final String str, final char trailingCharacter) {
      if (!StringUtils.hasLength(str)) {
        return str;
      }
  
      final StringBuilder sb = new StringBuilder(str);
      while (sb.length() > 0 && sb.charAt(sb.length() - 1) == trailingCharacter) {
        sb.deleteCharAt(sb.length() - 1);
      }
      return sb.toString();
    }
docs: Trim all occurrences of the supplied trailing character from the given {@code String}.
  
  @param str the {@code String} to check
  @param trailingCharacter the trailing character to be trimmed
  @return the trimmed {@code String}