Subversion Repositories eFlore/Applications.cel

Rev

Rev 1672 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1672 Rev 2276
Line 299... Line 299...
299
	
299
	
300
	public static String formaterNombre(String s) {
300
	public static String formaterNombre(String s) {
301
		s = s.indexOf(".") < 0 ? s : s.replaceAll("0*$", "").replaceAll("\\.$", "");
301
		s = s.indexOf(".") < 0 ? s : s.replaceAll("0*$", "").replaceAll("\\.$", "");
302
		return s;
302
		return s;
-
 
303
	}
-
 
304
 
-
 
305
	// Prend un nombre décimal avec le spéparateur spécifié et le tronque à n décimales
-
 
306
	public static String tronquerNombrePourAffichage(String nombre, int decimales, char separateur) {
-
 
307
		String retour = nombre;
-
 
308
		int posSep = nombre.indexOf(separateur);
-
 
309
		if (posSep >= 0) {
-
 
310
			int taille = posSep + decimales + 1;
-
 
311
			if (nombre.length() < taille) {
-
 
312
				taille = nombre.length();
-
 
313
			}
-
 
314
			retour = nombre.substring(0, taille);
-
 
315
		}
-
 
316
		return retour;
-
 
317
	}
-
 
318
 
-
 
319
	public static String tronquerNombrePourAffichage(String nombre, int decimales) {
-
 
320
		return tronquerNombrePourAffichage(nombre, decimales, '.');
303
	}
321
	}