本文介绍了f:convertNumber删除逗号作为千位分隔符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将小数点后四位的值四舍五入到小数点后一位.这就是为什么我使用f:convertNumber:

I want to round value with four decimal places to one decimal place. That is why I use f:convertNumber:

<h:outputText value="${current.dayAverage.pressureRelative}" >
    <f:convertNumber maxFractionDigits="1"/>
</h:outputText>

四舍五入是正确的,但是f:convertNumber添加了千位逗号分隔符.我想删除此分隔符,但不知道如何.我正在使用Apache MyFaces 2.1实现.在 f:convertNumber的API 中,它没有任何属性指定千位分隔符.我想这可以在locale属性中定义吗?

The rounding is done right, but the f:convertNumber adds thousand comma separator. I want to remove this separator but I don't know how. I am using Apache MyFaces 2.1 implementation. In the API for f:convertNumber it does not have any attribute to specify thousand separator. I suppose that this could be defined in locale attribute?

推荐答案

您是正确的,因为默认语言环境.您有几种选择:

You are right, its because of default locale. You have several options:

1.从faces-config设置默认语言环境:

 <locale-config>
    <default-locale>de</default-locale>
    <supported-locale>en_US</supported-locale>
    <supported-locale>es</supported-locale>
    <supported-locale>de</supported-locale>
    <supported-locale>fr_FR</supported-locale>
    <supported-locale>it_IT</supported-locale>
    <supported-locale>pt_br</supported-locale>
  </locale-config>

2.从支持的bean设置区域设置并通过转换器读取:

<f:convertNumber locale="#{bean.locale}" />

3.在转换器上设置本地:

<f:convertNumber locale="en-US" />

非常感谢 BalusC ,他回答了所有问题:)可以找到另外一个查看示例,所以我感到有点内and,并获得可用本地人的输出(格式为1000000):

Well thanks to BalusC he answered all the questions:) there you can find also view example, so i felt little bit guilty and get output for available locals (1000000 formatted):

ja_JP   Japanese (Japan)        1,000,000
es_PE   Spanish (Peru)      1.000.000
en  English     1,000,000
ja_JP_JP    Japanese (Japan,JP)     1,000,000
es_PA   Spanish (Panama)        1,000,000
sr_BA   Serbian (Bosnia and Herzegovina)        1.000.000
mk  Macedonian      1.000.000
es_GT   Spanish (Guatemala)     1,000,000
ar_AE   Arabic (United Arab Emirates)       1,000,000
no_NO   Norwegian (Norway)      1 000 000
sq_AL   Albanian (Albania)      1.000.000
bg  Bulgarian       1 000 000
ar_IQ   Arabic (Iraq)       1,000,000
ar_YE   Arabic (Yemen)      1,000,000
hu  Hungarian       1 000 000
pt_PT   Portuguese (Portugal)       1.000.000
el_CY   Greek (Cyprus)      1.000.000
ar_QA   Arabic (Qatar)      1,000,000
mk_MK   Macedonian (Macedonia)      1.000.000
sv  Swedish     1 000 000
de_CH   German (Switzerland)        1'000'000
en_US   English (United States)     1,000,000
fi_FI   Finnish (Finland)       1 000 000
is  Icelandic       1.000.000
cs  Czech       1 000 000
en_MT   English (Malta)     1,000,000
sl_SI   Slovenian (Slovenia)        1.000.000
sk_SK   Slovak (Slovakia)       1 000 000
it  Italian     1.000.000
tr_TR   Turkish (Turkey)        1.000.000
zh  Chinese     1,000,000
th  Thai        1,000,000
ar_SA   Arabic (Saudi Arabia)       1,000,000
no  Norwegian       1 000 000
en_GB   English (United Kingdom)        1,000,000
sr_CS   Serbian (Serbia and Montenegro)     1.000.000
lt  Lithuanian      1 000 000
ro  Romanian        1.000.000
en_NZ   English (New Zealand)       1,000,000
no_NO_NY    Norwegian (Norway,Nynorsk)      1 000 000
lt_LT   Lithuanian (Lithuania)      1 000 000
es_NI   Spanish (Nicaragua)     1,000,000
nl  Dutch       1.000.000
ga_IE   Irish (Ireland)     1,000,000
fr_BE   French (Belgium)        1.000.000
es_ES   Spanish (Spain)     1.000.000
ar_LB   Arabic (Lebanon)        1,000,000
ko  Korean      1,000,000
fr_CA   French (Canada)     1 000 000
et_EE   Estonian (Estonia)      1 000 000
ar_KW   Arabic (Kuwait)     1,000,000
sr_RS   Serbian (Serbia)        1.000.000
es_US   Spanish (United States)     1,000,000
es_MX   Spanish (Mexico)        1,000,000
ar_SD   Arabic (Sudan)      1,000,000
in_ID   Indonesian (Indonesia)      1.000.000
ru  Russian     1 000 000
lv  Latvian     1 000 000
es_UY   Spanish (Uruguay)       1.000.000
lv_LV   Latvian (Latvia)        1 000 000
iw  Hebrew      1,000,000
pt_BR   Portuguese (Brazil)     1.000.000
ar_SY   Arabic (Syria)      1,000,000
hr  Croatian        1.000.000
et  Estonian        1 000 000
es_DO   Spanish (Dominican Republic)        1,000,000
fr_CH   French (Switzerland)        1'000'000
hi_IN   Hindi (India)       ?,???,???
es_VE   Spanish (Venezuela)     1.000.000
ar_BH   Arabic (Bahrain)        1,000,000
en_PH   English (Philippines)       1,000,000
ar_TN   Arabic (Tunisia)        1,000,000
fi  Finnish     1 000 000
de_AT   German (Austria)        1.000.000
es  Spanish     1.000.000
nl_NL   Dutch (Netherlands)     1.000.000
es_EC   Spanish (Ecuador)       1.000.000
zh_TW   Chinese (Taiwan)        1,000,000
ar_JO   Arabic (Jordan)     1,000,000
be  Belarusian      1 000 000
is_IS   Icelandic (Iceland)     1.000.000
es_CO   Spanish (Colombia)      1.000.000
es_CR   Spanish (Costa Rica)        1,000,000
es_CL   Spanish (Chile)     1.000.000
ar_EG   Arabic (Egypt)      1,000,000
en_ZA   English (South Africa)      1,000,000
th_TH   Thai (Thailand)     1,000,000
el_GR   Greek (Greece)      1.000.000
it_IT   Italian (Italy)     1.000.000
ca  Catalan     1.000.000
hu_HU   Hungarian (Hungary)     1 000 000
fr  French      1 000 000
en_IE   English (Ireland)       1,000,000
uk_UA   Ukrainian (Ukraine)     1 000 000
pl_PL   Polish (Poland)     1 000 000
fr_LU   French (Luxembourg)     1 000 000
nl_BE   Dutch (Belgium)     1.000.000
en_IN   English (India)     1,000,000
ca_ES   Catalan (Spain)     1.000.000
ar_MA   Arabic (Morocco)        1,000,000
es_BO   Spanish (Bolivia)       1.000.000
en_AU   English (Australia)     1,000,000
sr  Serbian     1.000.000
zh_SG   Chinese (Singapore)     1,000,000
pt  Portuguese      1.000.000
uk  Ukrainian       1 000 000
es_SV   Spanish (El Salvador)       1,000,000
ru_RU   Russian (Russia)        1 000 000
ko_KR   Korean (South Korea)        1,000,000
vi  Vietnamese      1.000.000
ar_DZ   Arabic (Algeria)        1,000,000
vi_VN   Vietnamese (Vietnam)        1.000.000
sr_ME   Serbian (Montenegro)        1.000.000
sq  Albanian        1.000.000
ar_LY   Arabic (Libya)      1,000,000
ar  Arabic      1,000,000
zh_CN   Chinese (China)     1,000,000
be_BY   Belarusian (Belarus)        1 000 000
zh_HK   Chinese (Hong Kong)     1,000,000
ja  Japanese        1,000,000
iw_IL   Hebrew (Israel)     1,000,000
bg_BG   Bulgarian (Bulgaria)        1 000 000
in  Indonesian      1.000.000
mt_MT   Maltese (Malta)     1,000,000
es_PY   Spanish (Paraguay)      1.000.000
sl  Slovenian       1.000.000
fr_FR   French (France)     1 000 000
cs_CZ   Czech (Czech Republic)      1 000 000
it_CH   Italian (Switzerland)       1'000'000
ro_RO   Romanian (Romania)      1.000.000
es_PR   Spanish (Puerto Rico)       1,000,000
en_CA   English (Canada)        1,000,000
de_DE   German (Germany)        1.000.000
ga  Irish       1,000,000
de_LU   German (Luxembourg)     1.000.000
de  German      1.000.000
es_AR   Spanish (Argentina)     1.000.000
sk  Slovak      1 000 000
ms_MY   Malay (Malaysia)        1,000,000
hr_HR   Croatian (Croatia)      1.000.000
en_SG   English (Singapore)     1,000,000
da  Danish      1.000.000
mt  Maltese     1,000,000
pl  Polish      1 000 000
ar_OM   Arabic (Oman)       1,000,000
tr  Turkish     1.000.000
th_TH_TH    Thai (Thailand,TH)      ?,???,???
el  Greek       1.000.000
ms  Malay       1,000,000
sv_SE   Swedish (Sweden)        1 000 000
da_DK   Danish (Denmark)        1.000.000
es_HN   Spanish (Honduras)      1,000,000

这篇关于f:convertNumber删除逗号作为千位分隔符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-25 13:11