ho avuto un codice perfettamente funzionante ieri, nella forma precisa di:"IllegalFormatConversionException: d! = Java.lang.String" quando il numero di riempimento con 0s?
int lastRecord = 1;
String key = String.format("%08d", Integer.toString(lastRecord));
che avrebbe pad è ben al 00000001.
Ora ho preso a calci su una tacca con twoKeyChar ottenere una stringa da una tabella e lastRecord ottenere un int da una tabella.
Come potete vedere il concetto è essenzialmente lo stesso - converto un int in una stringa e provo a riempirlo con 0s; tuttavia, questa volta ottengo il seguente errore:
java.util.IllegalFormatConversionException: d != java.lang.String
Il codice è qui sotto:
String newPK = null;
String twoCharKey = getTwoCharKey(tablename);
if (twoCharKey != null) {
int lastRecord = getLastRecord(tablename);
lastRecord++;
//The println below outputs the correct values: "RU" and 11.
System.out.println("twocharkey:"+twoCharKey+"record:"+lastRecord+"<");
//Now just to make it RU00000011
newPK = String.format("%08d", Integer.toString(lastRecord));
newPK = twoCharKey.concat(newPK);
}
Mi sento come se devo aver digitato qualcosa di sbagliato, perché non v'è alcun motivo per la rottura in quanto la l'ultima volta in cui ha funzionato. Qualsiasi aiuto/suggerimento è apprezzato! Grazie!
In forma umana, che dice "l'identificatore di formato' d' non si applica ai valori di stringa ". –