java.util.IllegalFormatConversionException: %d can't format java.lang.String arguments

java.util.IllegalFormatConversionException: %d can't format java.lang.String arguments

%d 不能格式化String类型

int i = 5;

String s = i+"";

String format = String.format("%07d", s));//报错

String format = String.format("%07d", Integer.parseInt(s));//正确
String format = 0000005;

你可能感兴趣的:(java.util.IllegalFormatConversionException: %d can't format java.lang.String arguments)