StringBuilderUtils { @NonNull public static StringBuilder substring(@NonNull StringBuilder stringBuilder, int start, int end) { StringBuilder newStringBuilder = new StringBuilder(stringBuilder); newStringBuilder.replace(end, stringBuilder.length(), EMPTY); newStringBuilder.replace(0, start, EMPTY); return newStringBuilder; }  static void replace(@NonNull StringBuilder stringBuilder,
                        @NonNull String toReplace,
                        @NonNull String replacement); static void trim(@NonNull StringBuilder stringBuilder); static boolean isEmpty(@NonNull StringBuilder stringBuilder); static boolean startsWith(@NonNull StringBuilder stringBuilder, @NonNull String start); static boolean contains(@NonNull StringBuilder stringBuilder, @NonNull String contains); static boolean equals(@NonNull StringBuilder stringBuilder, @NonNull String equal); @NonNull static StringBuilder substring(@NonNull StringBuilder stringBuilder, int start, int end);  }
@Test public void substring() { StringBuilder stringBuilder = new StringBuilder("abcdefg"); String string = "abcdefg"; Assert.assertEquals(StringBuilderUtils.substring(stringBuilder, 1, 5).toString(), string.substring(1, 5)); }