If you do not want to convert StringBuilder to String or you need to continue to use it / save, then you can do something like this ...
for (int index = 0; index < sb.length(); index++) { if (sb.charAt(index) == '-') { sb.setCharAt(index, '/'); } }
If you don't care, you can do something like ...
String value = sb.toString().replace("-", "/");
source share