0
I need to format the following string with the respective parameter, but this generating the following error:
Caused by: java.util.Illegalformatconversionexception: %d can’t format java.lang.String Arguments
private static final String URL_HOST = "http://xxxx.com/";
private static final String URL_VERIFICA_ATUALIZACAO = "aaaa/%d";
String url = String.format(URL_HOST + URL_VERIFICA_ATUALIZACAO, ultimaConfiguracao.getUltima_atualizacao()); //retorna um Long (valor zero)
Estate:
@DatabaseField(dataType = DataType.LONG, canBeNull = false, defaultValue = "0")
private long ultima_atualizacao;
public long getUltima_atualizacao() {
return ultima_atualizacao;
}
public void setUltima_atualizacao(long ultima_atualizacao) {
this.ultima_atualizacao = ultima_atualizacao;
}
Sure the error is on this msm line? I did a test here and can’t imagine what might be causing the error. Try making a Minimum, Complete and Verifiable Example
– Math
@Math is doing this within an asynchronous method, which until now was generating other errors, but the last one is this... (I’m inexperienced on Android), I created the entire code of a necessary class and now I’m testing, I do not believe it is a bug Android Studio accuse the error in the wrong line...
– Luiz Negrini
Friend, does the error persist? If yes, I am reproducing the error here, and it is returning normal when I use a
Long
, orInt
, but the mistake is right when it isString
... What this part definesdefaultValue = "0"
in the annotation above the property?– Gustavo Cinque
@Gustavocinque he says that the default value is zero, I managed to solve the problem but I did not understand why it occurs, I did the test and I switched for string, but it was strange because in fact it is a Long... will understand?
– Luiz Negrini
Um... for me when I use
String
is when it goes wrong. I thought thatdefaultValue = "0"
defines the value of Long in the database as Character or something, but I believe that.– Gustavo Cinque
It just arrow the default value to long zero.
– Luiz Negrini