if you have a special use-case where you need to keep this "0" prefix as well as use it as a numeric value, you should build a custom class for it. For instance, let's assume this number is introduced by the user in some input field on the screen. the class can look like this (it can even be a record):
public class UserInput {
private final String originalString;
private final int value;
public UserInput(String originalString) {
this.originalString = originalString;
this.value = Integer.valueOf(originalString);
}
public String text() {
return originalString;
}
public int numericValue() {
return value;
}
}
now you can create UserInput by providing the original Stirng and use any of the numericValue method for comparison and mathematical operations:
UserInput previousInput = new UserInput("000039");
UserInput input = new UserInput("0040");
System.out.println("value introduced: " + input.text());
System.out.println("numeric value increased: " + input.numericValue() > previousInput.numericValue());
is this what you needed?