From the java.text.ChoiceFormat
API:
setChoices(double[] limits, String[] formats)
: Set the choices to be used in formatting.Parameters:
limits
- contains [...]formats
- are the formats you want to use for each limit. They can be eitherFormat
objects orString
s. When formatting with objectY
, if the object is aNumberFormat
, then((NumberFormat) Y).format(X)
is called. OtherwiseY.toString()
is called.
I'm having difficulties understanding the documentation for the formats
parameter: how can you possibly pass a Format/NumberFormat
object to setChoices
if it's declared String[] formats
?
Note that interestingly, the getters counterpart of setChoices
are declared as follows:
double[] getLimits()
Object[] getFormats()
-- notString[]
!!!
Is this a bug in the API? Should the setter have been declared setChoices(double[], Object[])
instead, or am I not understanding how to use setChoices
correctly?