commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From paulbeuk <paul.van.beuker...@gmail.com>
Subject Re: Math - Fractions 3/2 to 1 1/2
Date Tue, 23 Nov 2010 14:48:56 GMT

Hello Mikkel,

Thanks! (great for recipes)

FractionFormat format = FractionFormat.getProperInstance();
Fraction f = new Fraction(5,2);
String s = format.format(f).replaceAll(" / ", "/");
s = s.replaceAll(" 0/1", "");
System.out.println("s : " + s ); = 2 1/2

Fraction f = new Fraction(2,2);
String s = format.format(f).replaceAll(" / ", "/");
s = s.replaceAll(" 0/1", "");
System.out.println("s : " + s ); = 1



-- 
View this message in context: http://apache-commons.680414.n4.nabble.com/Math-Fractions-3-2-to-1-1-2-tp3055391p3055571.html
Sent from the Commons - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org


Mime
View raw message