Olá pessoal, preciso fazer com que meu código seja executado em no máximo 3s. só que não sei como substituir as gambiarras que fiz. tem varias transformações de String para int e int para char.
public static int centuryFromYear(int year) {
String aux;
String anoString = String.valueOf(year);
if(year >= 1 && year <= 2005){
if(year % 10 == 0) {
if(year >= 1000) {
aux = anoString.charAt(0) + "" + anoString.charAt(1);
return year = Integer.parseInt(aux);
}else {
char auxs = anoString.charAt(0);
return year = Character.getNumericValue(auxs);
}
}else {
if(year >= 1001) {
aux = anoString.charAt(0) + "" + anoString.charAt(1);
return year = Integer.parseInt(aux) + 1;
}else if(year >= 101) {
char auxs = anoString.charAt(0);
return year = Character.getNumericValue(auxs) + 1;
}else{
return year = 1;
}
}
}
return year;
}`
