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 ...
随机推荐
- webpack入门指南-step01
一.webpack是什么? web开发中常用到的静态资源主要有JavaScript.CSS.图片.Jade等文件,webpack中将静态资源文件称之为模块.webpack是一个模块打包工具(命令行工具 ...
- 直接抱过来dd大牛的《背包九讲》来做笔记
P01: 01背包问题 题目 有N件物品和一个容量为V的背包.第i件物品的费用是c[i],价值是w[i].求解将哪些物品装入背包可使这些物品的费用总和不超过背包容量,且价值总和最大. 基本思路 这是最 ...
- 第七次作业PSP
psp 进度条 代码累积折线图 博文累积折线图 psp饼状图
- 第五周PSP作业
PSP表格: 累积进度条: 折线图: 饼状图:
- tensorboard入门
Tensorboard tensorboard用以图形化展示我们的代码结构和图形化训练误差等,辅助优化程序 tensorboard实际上是tensorflow机器学习框架下的一个工具,需要先安装ten ...
- P4 Runtime和p4 info
p4runtime P4 Runtime是一套基于Protobuf以及gRPC框架上的协议,通过P4runtime,SDN控制器可以控制能够支援p4的设备. p4runtime当前由p4 API wo ...
- 使用qemu-img创建虚拟磁盘文件
# 安装qemu-img yum install -y qemu-img # 获取帮助 qemu-img --help # 支持的虚拟磁盘文件格式 Supported formats: vvf ...
- 使用.bat文件运行ant的build.xml
1.新建一个txt文件 2.复制下面命令到txt文件 echo "Start build..." call ant.bat -f "E:\build.xml" ...
- 性能测试工具Loadrunner使用经验小结(原创更新版)
1. 引言 1.1. 简介 loadrunner是一种预测系统行为和性能的负载测试工具,它可以轻松创建虚拟用户.创建真实的负载.定位性能问题.重复测试保证系统的高性能 globa-100的注册码:AE ...
- 程序员必看电影:Java 4-ever
http://blog.csdn.net/zdwzzu2006/article/details/5863068