Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

JSP <fmt:formatNumber> problem

  • 28-01-2004 05:47PM
    #1
    Registered Users, Registered Users 2 Posts: 4,228 ✭✭✭


    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, Registered Users 2 Posts: 68,173 ✭✭✭✭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