public class FractionFormat
extends java.text.Format
Format class that handles Excel style fractions, such as "# #/#" and "#/###"
As of this writing, this is still not 100% accurate, but it does a reasonable job of trying to mimic Excel's fraction calculations. It does not currently maintain Excel's spacing.
This class relies on a method lifted nearly verbatim from org.apache.math.fraction. If further uses for Commons Math are found, we will consider adding it as a dependency. For now, we have in-lined the one method to keep things simple.
| Constructor and Description |
|---|
FractionFormat(java.lang.String wholePartFormatString,
java.lang.String denomFormatString)
Single parameter ctor
|
| Modifier and Type | Method and Description |
|---|---|
java.lang.String |
format(java.lang.Number num) |
java.lang.StringBuffer |
format(java.lang.Object obj,
java.lang.StringBuffer toAppendTo,
java.text.FieldPosition pos) |
java.lang.Object |
parseObject(java.lang.String source,
java.text.ParsePosition pos) |
public FractionFormat(java.lang.String wholePartFormatString,
java.lang.String denomFormatString)
denomFormatString - The format string for the denominatorpublic java.lang.String format(java.lang.Number num)
public java.lang.StringBuffer format(java.lang.Object obj,
java.lang.StringBuffer toAppendTo,
java.text.FieldPosition pos)
format in class java.text.Formatpublic java.lang.Object parseObject(java.lang.String source,
java.text.ParsePosition pos)
parseObject in class java.text.FormatCopyright © 2007–2023. All rights reserved.