Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

JSP <fmt:formatNumber> problem

Options
  • 28-01-2004 5:47pm
    #1
    Registered Users Posts: 4,222 ✭✭✭


    when doing the following operation

    <fmt:formatNumber var="totalin" value="${totalrow.Received}" />
    <fmt:formatNumber var="totalout" value="${totalrow.Sent}" />
    <fmt:formatNumber var="total" value="${totalin + totalout}" />

    i'm getting this error

    An error occurred while evaluating custom action attribute "value" with value "${totalin + totalout}": An exception occured trying to convert String "1,114" to type "java.lang.Long"

    where 1114 is the value returned to either totalin or totalout.

    its very weird. this error only crops up when one of the values to be added is > 999

    ??


Comments

  • Registered Users Posts: 68,317 ✭✭✭✭seamus


    You're attempting to add two formatted strings together. numberFormat I'm guessing adds in commas for the thousands.

    When it's a value under 1000, it autmatically casts them to long and adds them together. But if it's > 999 then, it formats it to x,xxx and then tries to cast to long, which it can't, since a comma isn't a number. :)

    replace "${totalin + totalout}"
    with "${totalrow.Received + totalrow.Sent}"


Advertisement