将双重格式化为iReport中的字符串 [英] Formatting Double into a String in iReport
本文介绍了将双重格式化为iReport中的字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如果我单独对待变量,我可以格式化它们没有问题。
但是当我将它们合并成一个字符串时,双重值就是0.0而不是0.00
如何使它成为原始的,0.00?
现在的代码看起来像这样:
$ F {someDoubleField} +一个字符串+ $ F {另一个DoubleField} +另一个字符串
它打印:
0.0一个字符串0.0另一个字符串
而不是:
0.00一个字符串0.00另一个字符串
记住,iReport使用Java,所以也许Java代码可以帮助我。
解决方案
使用如下:
new DecimalFormat(0.00)。format(doubleField)+str
I'm doing a report, that I need to join 4 variables in one. If I treat the variables separately I can format them with no problem. But when I merge them into a String, the double value comes as 0.0 instead of 0.00
How can I make it comes as the original, 0.00? The code right now looks like this:
$F{someDoubleField} + "a string" + $F{anotherDoubleField} + "another string"
It prints:
0.0 a string 0.0 another string
instead of:
0.00 a string 0.00 another string
Remember that iReport uses Java, so maybe, Java code can help me out.
解决方案
Use like below:
new DecimalFormat("0.00").format(doubleField) + "str"
这篇关于将双重格式化为iReport中的字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文