【发布时间】:2011-09-30 10:38:05
【问题描述】:
我在 Java 中使用 StringTemplate。
我想以一定的精度呈现十进制数(例如小数点后 3 位)。
ST对象可以做到吗?如何?
编辑: 澄清一下,这在渲染对象时尤其重要。例如。我的代码看起来像
String renderMe(String template, Collection<MyClass> items)
{
// render the items here using the template....
}
renderMe() 不必知道 MyClass 的字段,特别是它不必知道哪些字段是浮点数。我正在寻找一种能够保持这种解耦的解决方案。
【问题讨论】:
标签: java stringtemplate