【问题标题】:iReport 3.0.0: How to compare big decimals in field expressioniReport 3.0.0:如何比较字段表达式中的大小数
【发布时间】:2012-09-04 15:02:15
【问题描述】:

谁能告诉我如何比较 field 表达式 (textFieldExpression) 中的两个 Big Decimal 值?我正在使用 iReport 3.0.0

greater then 的语法是什么?

这是我的表达式,它有效,但仅显示两个值是否不相等,我需要检查哪个值更大 (amount > paid_amount)。

我正在使用这个表达式:

($F{paid_date}!=null & ($F{amount}.equals($F{paid_amount}))) ? new String ("PAID") :(
($F{paid_date}==null) ? new String ("NOT PAID"): (
($F{paid_date}!=null & (!$F{amount}.equals($F{paid_amount}))) ? new String ("PARTIALLY PAID"):(new String ("INVOICE MISSING "))))

【问题讨论】:

    标签: jasper-reports expression ireport bigdecimal


    【解决方案1】:

    对于这样的字段:

    <field name="amount" class="java.math.BigDecimal"/>
    <field name="paid_amount" class="java.math.BigDecimal"/>
    

    你应该使用这个表达式:

    <textFieldExpression class="java.lang.String"><![CDATA[$F{amount}.compareTo($F{paid_amount}) == 1 
    ? "The amount value is greater than the paid_amount value" 
    : $F{amount}.compareTo($F{paid_amount}) == 0 ? 
    "The amount value is equal to the paid_amount value" : 
    "The amount value is less than the paid_amount value"]]></textFieldExpression>
    

    这个表达式基于使用int BigDecimal.compareTo(java.math.BigDecimal val)方法。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-01-21
      • 2013-06-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多