Seems like an OK feature. +1. I would like to note that as a front-end I've never needed that level of flexibility for decimals since that logic has always been handled in the backend. I've really only ever needed to manipulate the format for locales. That's not to say the feature wouldn't be useful for a numbers-heavy app, e.g. something finance or statistics related.
On Wed, Sep 16, 2015 at 2:14 AM, Daniel Dekany <[email protected]> wrote: > The 72 hours for lazy-voting is almost out, and I only had input from > one person, and none from PMC members. Anyone wants to add anything? > > This VOTE will decide if there will be DecimalFormat option > assignments after the 2nd ";", as it was proposed (find it quoted > below). Except, how exactly the parameter names will look (like "rnd" > VS "rounding") will be figured out afterwards. > > BTW, I have renamed "ro" to "rnd", as that's more in line with "grp" > and such. OTOH it reads as "RaNDom" for most of us, so it's just > another compromise. > > The original proposal: > > > Because not many people are here yet, it will be lazy vote. Is that > > OK? 72 hours to go, unless there will be an active discussion of > > course. > > > > We had some RFE-s in past, where someone requested: > > - Using half-up rounding mode instead of the Java default half-even > > (https://sourceforge.net/p/freemarker/feature-requests/62/) > > - Overriding the symbol used for NaN > > (https://sourceforge.net/p/freemarker/feature-requests/67/) > > - Using dot as decimal separator for certain numbers, instead of > > the locale default (which was comma there) (but not the case of ?c) > > (https://sourceforge.net/p/freemarker/feature-requests/117/) > > > > I remember some other case (maybe it was just e-mail) where the user > > has complained that in general he can't use all the features of > > java.text.DecimalFormat as we only allow specifying the pattern > > string. > > > > The number format is specified with a string in FreeMarker. This is so > > in the Configurable API, also in FTL (<#setting number_format="0.##"> > > and n?string("0.##")). So I wondered how to allow specifying the > > parameters for DecimalFormat without making a mess, and found that we > > can just extend the string parsed by DecimalFormat with a new section, > > that would cause IllegalArgumentException if you pass it to > > DecimalFormat as is, so it's backward compatible to add such a > > section. > > > > DecimalFormat accepts almost all kind of random string without > > complaining. But it's string about ';'. DecmialFormat allows you to > > specify two patterns, one for the positive, and another for the > > negative numbers, separated by ';'. We could allow yet another ';' and > > a further section, where the properties of the Decimal format can be > > specified. So if someone wants '_' for grouping separator and half-up > > rounding mode, then instead of ",##0.##", he could use ",##0.##;; > > grp=_ ro=hu". The double ";;" is because the 2nd section (for negative > > number format) is empty. (This is backward compatible, as that's an > > error for pure DecimalFormat.) In general, the 3rd section will be a > > list of key=value pairs separated by whitespace and and optional > > comma. If a value needs quoting, the quotation rules of DecimalFormat > > patterns will be used (i.e, use apostrophe-quote, and double it for > > escaping). The allowed keys would be: > > > > - ro=u|d|c|f|hu|hd|he|un: RoundingMode > > - mul: Multipier > > - dec: DecimalSeparator > > - grp: GroupingSeparator > > - exp: ExponentSeparator > > - min: MinusSign > > - inf: Infinity > > - nan: NaN > > - prc: Percent > > - prm: PerMill > > - zero: ZeroDigit > > - curc: Currency (ISO 4217 Code) > > - curs: CurrencySymbol 2nd > > - icurs: InternationalCurrencySymbol > > - mdec: MonetaryDecimalSeparator > > > > I will add this feature, if you agree. > > -- > Thanks, > Daniel Dekany > > > > ------------------------------------------------------------------------------ > Monitor Your Dynamic Infrastructure at Any Scale With Datadog! > Get real-time metrics from all of your servers, apps and tools > in one place. > SourceForge users - Click here to start your Free Trial of Datadog now! > http://pubads.g.doubleclick.net/gampad/clk?id=241902991&iu=/4140 > _______________________________________________ > FreeMarker-devel mailing list > [email protected] > https://lists.sourceforge.net/lists/listinfo/freemarker-devel >
