Hello. I have such a question, I know how to add a line with zeros
System.out.println(String.format("%010d",123)); But how to replace 0 with another character?
Hello. I have such a question, I know how to add a line with zeros
System.out.println(String.format("%010d",123)); But how to replace 0 with another character?
In this case, for example, like this:
System.out.println(String.format("%10d", 123).replace(' ', 's')); How to implement this using standard String.format(...) in general , I will not say for sure. But this can be done with at least:
StringUtils.leftPad("test", 10, 's');Strings.padStart("test", 10, 's'); .It is also possible to implement the same method with a similar functional, for elementary.
Source: https://ru.stackoverflow.com/questions/575761/
All Articles
String.format("%10d",123).replace(' ', '*')- will not work? - PinkTux