code: public static String replaceLast(String source, char toReplace, char with) {
      StringBuilder sb = new StringBuilder(source);
      int index = sb.lastIndexOf(String.valueOf(toReplace));
      if (index != -1) {
        sb.setCharAt(index, with);
      }
      return sb.toString();
    }
docs: Static for access from enum.