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 ...
随机推荐
- 【Alpha】阶段第四次Scrum Meeting
[Alpha]阶段第四次Scrum Meeting 工作情况 团队成员 今日已完成任务 明日待完成任务 刘峻辰 获取课程评论接口 增加课程接口 赵智源 整合前端进行部署 整合前端进行部署 肖萌威 编写 ...
- 进阶系列(8)——匿名方法与lambda表达式
一 匿名方法的介绍 匿名方法是为了简化委托的实现,方便调用委托方法而出现的,同时,匿名方法也是学好lambda表达式的基础.在委托调用的方法中,如果方法只被调用一次,这个时候我们就没有必要创建 ...
- HDU 5207 Greatest Greatest Common Divisor
题目链接: hdu:http://acm.hust.edu.cn/vjudge/problem/visitOriginUrl.action?id=153598 bc(中文):http://bestco ...
- <<世界是数字的>>读书笔记
<世界是数字的>这本书是大学职业规划老师介绍个我读的,从着本中我学到了很多. 第一章,计算机里有什么.这个问题可以从两方面来看:逻辑上或者说功能上的组成,即每一部分是什么.做什么.怎样做. ...
- [图算法] 1030. Travel Plan (30)
1030. Travel Plan (30) A traveler's map gives the distances between cities along the highways, toget ...
- 虚拟机下安装CentOS6.5系统教程
虚拟机下安装CentOS6.5系统教程 时间:2014-12-09 01:40来源:linuxdown.net 作者:linuxdown.net 举报 点击:15315次 其实通过VM安装虚拟机还是蛮 ...
- win8平板APP开发的教程文章
http://blog.csdn.net/tcjiaan/article/details/7866595 基于C#的Metro工程如何引用C++的动态库——FIleNotFound解决办法: http ...
- jquery 集合注意点
- 【bzoj4311】向量 线段树对时间分治+STL-vector维护凸包
题目描述 你要维护一个向量集合,支持以下操作: 1.插入一个向量(x,y) 2.删除插入的第i个向量 3.查询当前集合与(x,y)点积的最大值是多少.如果当前是空集输出0 输入 第一行输入一个整数n, ...
- 【Java】接口开发中关于接受和发送json的相关范例
接受json package com.suneee.scn.wms.web.rocketmq; import java.util.List; import net.sf.json.JSONArray; ...