开发者

How do I format a number using jstl format tag?

开发者 https://www.devze.com 2023-03-28 04:22 出处:网络
I have a jsp page in which i need to display a number in this format. original number : 1234567890 Formatted number : 123-456-7890

I have a jsp page in which i need to display a number in this format.

original number : 1234567890 Formatted number : 123-456-7890

How can we accomplish this using jstl fmt tag?

To be precise what should be the value of the p开发者_JAVA技巧attern attribute?

Thanks


You can't. You need your custom tag to do that (it can still wrap NumberFormat). You can use

<fmt:formatNumber value=".." groupingUsed="true" />

To enable grouping, but the grouping separator will depend on the locale


You can look into something like this for your tag library implementation. It's from NetUI library

<netui:span value="2125555555">
        <netui:formatString pattern="phone (###) ###-####"/>
</netui:span> 

javadoc , source

0

精彩评论

暂无评论...
验证码 换一张
取 消