How do I format a number using jstl format tag?
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
精彩评论