速度模板中的数字格式至少2个小数点

发布于 2025-01-27 17:16:47 字数 188 浏览 3 评论 0原文

我必须格式化给定字符[132233.2453],例如 - > 132,233.2453

当前代码 - > $ number.format(“ ###,###。## 00”,$ value)

似乎工作正常,但对于字符[295] - >它应该是295.00 [小数点后至少2个字符],但即将到295 [没有任何小数点]

I have to format given character [132233.2453] like this -> 132,233.2453

current code -> $number.format("###,###.##00", $value)

which seems to be working fine, but for character [295] -> it should be 295.00 [minimum 2 characters after decimal points] but it is coming 295 [without any decimal points]

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

别挽留 2025-02-03 17:16:47

以速度,双引号的字符串被插值。在插值字符串中,##开始行注释。因此,基本上您的格式为空。

另外,小数规范应为00 ##,而不是## 00

因此,尝试:$ number.format('###,###。00 ##',$ value)

In Velocity, double quoted strings are interpolated. And in an interpolated string, ## starts a line comment. So basically your formats are empty.

Also, the decimal specification should be 00## and not ##00.

So try: $number.format('###,###.00##', $value)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文