fmt:formatNumber use locale display negative currency in -$xxx.xx format in JSTL
First, we want to know our own locale,how to display the locale in a JSTL?
<c:out value="${pageContext.request.locale.language}"/>
I'm confused with the jstl tag libs:
I want to format a number to a currency with german style
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<html>
<head>
<title>format number</title>
</head>
<body>
<c:set var="val" value="40.52" />
<p> Currency in USA
<fmt:setLocale value="en_US"scope="session"
/>
<fmt:formatNumber value="${val}" type="currency" />
</p>
<p>Currency in Germany
<fmt:setLocale value="de_DE"scope="session"
/>
<fmt:formatNumber value="${val}" type="currency"/>
</p>
</body>
</html>
And thats the output:
Currency in USA $40.52
Currency in Germany 40,52 €
I am using fmt:formatNumber to format currency in JSTL, it will display negative currency in ($100) format, if you want to make it display negative currency in negative format instead of ($100). I would suggest:
<c:set
var="val" value="46563746375"/> <fmt:formatNumber
value="${val}" pattern="###.###E0"/> If you run the above code you will see the number is formatted as the pattern which is 46.5637E9 . |
fmt:formatNumber use locale display negative currency in -$xxx.xx format in JSTL的更多相关文章
- <fmt:formatNumber>标签
<fmt:formatNumber>标签用于格式化数字,百分比,货币. 属性 <fmt:formatNumber>标签有如下属性: 属性 描述 是否必要 默认值 value 要 ...
- JSTL fmt:formatNumber 数字、货币格式化
<fmt:formatNumber value="12.34" pattern="#0.00" /> 12.34 保留小数点后两位数 <fmt ...
- jstl <fmt:formatNumber>标签
标签用于格式化数字,百分比和货币. 如果type属性为百分比或数字,则可以使用多个数字格式属性.maxIntegerDigits和minIntegerDigits属性允许您指定数字的非分数部分的大小. ...
- JSTL标签库中fmt标签,日期,数字的格式化
首先介绍日期的格式化:(不要嫌多哦) JSTL格式化日期(本地化) 类似于数字和货币格式化,本地化环境还会影响生成日期和时间的方式. <%@ page pageEncoding="UT ...
- JSP标准标签库(JSTL)--国际化标签库 fmt
JSTL中使用fmt.tld作为格式化标签库的定义文件 No. 功能分类 标签名称 描述 1 国际化标签 <fmt:setLocale> 设置一个全局的地区代码 2 <fmt:req ...
- (2)JSTL的fmt国际化标签库
format标签库:做国际化格式化,分两类 : 国际化核心标签:<fmt:setLocale>.<fmt:bundle>.<fmt:setBundle>.<f ...
- JSTL中fmt标签详解
一:JSTL格式化标签又称为I18N标签库,主要用来编写国际化的WEB应用,使用此功能可以对一个特定的语言请求做出合适的处理. 例如:中国内地用户将显示简体中文,台湾地区则显示繁体中文,使用I18N格 ...
- JSTL——formatNumber标签
使用场合: <fmt:formatNumber>标签用于格式化数字,百分比,货币 属性: 语法 如果使用pattern属性.这个属性可以让您在对数字编码时包含指定的字符.接下来的表格中列出 ...
- jsp中引用的jstl 和fmt标签-详解
JSTL 核心标签库标签共有13个,功能上分为4类: 1.表达式控制标签:out.set.remove.catch 2.流程控制标签:if.choose.when.otherwise 3.循环标签:f ...
随机推荐
- QT中文乱码解决方法
由于我毕设的界面是用Qt做的,之前没怎么接触过Qt,所以实现过程中遇到不少小问题,头一个就是这个. 现如今宝宝将其记录下来,供同样有需要的同学或者自己以后方便查阅. 1.所有文件编码格式须一致 不统一 ...
- “我爱淘”第二冲刺阶段Scrum站立会议3
完成任务: 完成了注册界面的设计,以及部分代码,但是还没有完成服务器端的添加功能. 计划任务: 将注册功能实现了它,可以对数据库进行添加,在客户端实现分类功能,通过学院的分类查看书籍. 遇到问题: 分 ...
- CS小分队第一阶段冲刺站立会议(5月12日)
昨日成果:2048整体界面效果经组员韩雪冬美化之后档次提升了好几个,我为其添加了保存并显示最高分数的功能. 遇到困难:当我想把access数据库由accdb改成mdb时,发生未知错误 ,导致数据库无法 ...
- 博弈---ZOJ 2083 Win the Game(染绳子)
原题:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=2083 大意:两个人分别对n条绳子染 每次染m长 最后染不下的输,问先 ...
- nodepad++ 格式化xml插件
1.用插件管理器安装xmltools插件 2.使用如下菜单格式化xml: 所有插件下载地址: http://sourceforge.net/projects/npp-plugins/files/
- 0330复利计算java版
package compounding; import java.util.Scanner; public class compounding1_1 { public static void main ...
- session的基本原理
转载:http://blog.sina.com.cn/s/blog_8155e74d0101iqmh.html 如何严格限制session在30分钟后过期! 1.设置客户端cookie的lifetim ...
- ZOJ2083_Win the Game
这个题目很有趣,有博弈知识,又有一点智商题的感觉. 题意为给你一段长为n的的线段. 两个游戏者轮流在一段长为2,未被染色的线段上涂色. 无法涂色的游戏者输. 题目有点灵活.关键在于怎么得到Sg函数值呢 ...
- 洛谷 [USACO09OPEN]工作调度
题面 读完题,我们会发现有一个很重要的信息,每件物品代价相同,但价值不同.那么我们很容易想到,在满足限制的情况下,我们肯定会选择价值尽可能大的物品. 我们可否用背包来实现呢,答案是否定的,或者说我不会 ...
- python 内存问题(glibc库的malloc相关)
题记: 这是工作以来困扰我最久的问题.python 进程内存占用问题. 经过长时间断断续续的研究,终于有了一些结果. 项目(IM服务器)中是以C做底层驱动python代码,主要是用C完成 网络交互部分 ...