301,4 → 301,22 |
s = s.indexOf(".") < 0 ? s : s.replaceAll("0*$", "").replaceAll("\\.$", ""); |
return s; |
} |
|
// Prend un nombre décimal avec le spéparateur spécifié et le tronque à n décimales |
public static String tronquerNombrePourAffichage(String nombre, int decimales, char separateur) { |
String retour = nombre; |
int posSep = nombre.indexOf(separateur); |
if (posSep >= 0) { |
int taille = posSep + decimales + 1; |
if (nombre.length() < taille) { |
taille = nombre.length(); |
} |
retour = nombre.substring(0, taille); |
} |
return retour; |
} |
|
public static String tronquerNombrePourAffichage(String nombre, int decimales) { |
return tronquerNombrePourAffichage(nombre, decimales, '.'); |
} |
} |