我在Java中使用StringTemplate。如何在Java中使用StringTemplate(ST)格式化十進制數字?
我想呈現一定精度的十進制數(例如小數點後的3位數)。
ST對象可以做到嗎?如何?
編輯: 澄清,這是渲染對象時尤其相關。例如。我的代碼看起來像
String renderMe(String template, Collection<MyClass> items)
{
// render the items here using the template....
}
renderMe()不必知道MyClass的領域的東西,尤其是它並不需要知道哪些字段浮點。我正在尋找解決方案來維持這種解耦。
考慮還包括這種模板的預期呈現。 – 2012-06-16 00:02:14