ibm - xpages - Get rid of the fraction part of a currency -
i'm trying rid of fraction part of field stored in notes document number
field. in xpages displays default double want convert currency. when use standard currency converter can't rid of fraction part.
i tried convert double display integer only
, programmatically converted double intvalue. works fine long don't use currency converter seem add fractions no matter what. guess because default fractionpart
2.
i guess 1 important clue i'm talking swedish currency. in sweden display currency in pattern: # ### ### kr
. punctuation space , currency symbol after number.
i tried use custom converter - pattern
above example don't punctuation correct. - i'm trying achieve this: example: 112 000 kr
code example return this: 112 000,00 kr
of course can string conversion-concatenation operation
achieve best if there's way hold of default fraction part
currencycode , manipulate that..? , me seems bug
because "display integer only"
seems disregarded.
maybe there pattern conversion
haven't found, can use?
code examples:
<xp:inputtext value="#{document1.totsumcost}" id="totsumcost1"> <xp:this.converter> <xp:convertnumber type="currency" currencysymbol="kr" currencycode="sek" integeronly="true" maxfractiondigits="0"> </xp:convertnumber> </xp:this.converter> </xp:inputtext>
i "sort of" solved myself in disturbing way:
<xp:inputtext value="#{document1.totsumcost}" id="inputtext2"> <xp:this.converter> <xp:convertnumber type="currency" integeronly="true" locale="sv" maxfractiondigits="0" currencysymbol=" "> </xp:convertnumber> </xp:this.converter> </xp:inputtext> <xp:text escape="true" id="computedfield6"> <xp:this.value><![cdata[#{javascript:return " kr"}]]></xp:this.value> </xp:text>
use custom converter:
<xp:this.converter> <xp:customconverter> <xp:this.getasstring><![cdata[#{javascript: value.tofixed(0).replace(/(\d)(?=(\d{3})+(?!\d))/g, "$1 ") + " kr" }]]></xp:this.getasstring> <xp:this.getasobject><![cdata[#{javascript: parsefloat(value.replace(" ", "")) }]]></xp:this.getasobject> </xp:customconverter> </xp:this.converter>
it converts numbers swedish currency format like
123456789.12
--> 123 456 789 kr
, parses float.
if want save value integer use parseint()
instead of parsefloat()
.
Comments
Post a Comment