“IllegalFormatConversionException: d != java.lang.String” when padding number with 0s?

前端 未结 2 1511
别跟我提以往
别跟我提以往 2021-01-11 10:07

I had a perfectly working code yesterday, in the exact form of:

int lastRecord = 1;
String key = String.format(\"%08d\", Integer.toString(lastRecord));
         


        
2条回答
  •  萌比男神i
    2021-01-11 11:00

    You don't need the Integer.toString():

     newPK = String.format("%08d", lastRecord);
    

    String.format() will do the conversion and the padding.

提交回复
热议问题