jstl格式化数字
jstl中的<fmt:formatNumber>标签
<%
request.setAttribute("currentTimeStamp",Calendar.getInstance().getTime());
%>
显示:2009-11
<fmt:formatDate pattern="yyyy-MM" value="${currentTimeStamp}"/> <br/>
显示:2009-11-30 23:47:06
<fmt:formatDate pattern="yyyy-MM-dd HH:mm:ss" value="${currentTimeStamp}"/> <br/>
显示:$12.00
<fmt:formatNumber value="12" type="currency" pattern="$.00"/> <br/>
显示:$12.0
<fmt:formatNumber value="12" type="currency" pattern="$.#"/> <br/>
¥12.0
<fmt:formatNumber value="12" type="currency" pattern="¥.00"/> <br/>
12.00元
<fmt:formatNumber value="12" type="currency" pattern="#0.00元"/> <br/>
¥12.00
<fmt:formatNumber value="12" type="currency"/> (那个货币的符号和当前web服务器的 local 设定有关)<br/>
123456.79
<fmt:formatNumber value="123456.7891" pattern="#0.00"/> <br/>
123,456.79
<fmt:formatNumber value="123456.7891" pattern="#,#00.00"/> <br/>
.79
<fmt:formatNumber value="0.7891" pattern="#.00"/> <br/>
12.34%
<fmt:formatNumber value="0.1234" type="percent" pattern="#0.00%"/><br/>
1,200%
<fmt:formatNumber value="12" type="percent" /><br/>
1200.00%
<fmt:formatNumber value="12" type="percent" pattern="#0.00%"/><br/>
------------------------------------------------------------------------------
java格式化输出:
DecimalFormat df = new DecimalFormat("格式");
String fmt =df.format(double);
符号 意义
0 一个数位
# 一个数位,前导零和追尾零不显示
. 小数点分割位置
, 组分隔符的位置
- 负数前缀
% 用100乘,并显示百分号
其他任何符号 在输出字符串中包括指定符号
jstl格式化数字的更多相关文章
- JSP页面格式化数字或时间 基于jstl的
jsp页面格式化数字或时间 转载自: http://blog.csdn.net/hakunamatata2008/archive/2011/01/21/6156203.aspx Tags fmt:re ...
- 在jsp页面中实现格式化数字,百分比,货币
当时的要求是在jsp页面中计算百分比 实现方法 1.引入Jstl的fmt指令 <%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" ...
- jstl 格式化
一:JSTL格式化标签又称为I18N标签库,主要用来编写国际化的WEB应用,使用此功能可以对一个特定的语言请求做出合适的处理.例如:中国内地用户将显示简体中文,台湾地区则显示繁体中文,使用I18N格式 ...
- JSTL格式化标签库
导入标签库需要使用taglib指令! <%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/forma ...
- java基础之——DecimalFormat格式化数字
DecimalFormat可以用来格式化数字,例如用来设定保留多少位小数.设定数字分隔符等. 说方法之前,先介绍一下其常用的几个模式占位符: 0 一个数字# 一个数字,不包括 0. 小数的分隔符的占位 ...
- js格式化数字和金额
格式化数字,格式化金额: function number_format(number, decimals, dec_point, thousands_sep) { /* * 参数说明: * numbe ...
- Smarty格式化数字为INT数
<? require("setup.php"); define('PAGETITLE','pagtitle'); function insert_top($lid,$sid) ...
- php number_format()保留小数点后几位有效数的函数 千位分组来格式化数字(转)
PHP保留小数点后2位的函数number_format number_format(带小数点的书,小数点后保留的位数) number_format(8.3486,2); //取得小数点后2位有效数/ ...
- php的格式化数字函数
php格式化数字:位数不足前面加0补足 php格式化数字:位数不足前面加0补足 感谢:http://www.cnblogs.com/xiaochaohuashengmi/archive/2011/12 ...
随机推荐
- aptitude解决Ubuntu各种依赖问题
转自:http://allog.ml/linux/aptitude%E8%A7%A3%E5%86%B3ubuntu%E5%90%84%E7%A7%8D%E4%BE%9D%E8%B5%96%E9%97% ...
- 大数据——Hadoop集群坏境CentOS安装
前言 前面我们主要分析了搭建Hadoop集群所需要准备的内容和一些提前规划好的项,本篇我们主要来分析如何安装CentOS操作系统,以及一些基础的设置,闲言少叙,我们进入本篇的正题. 技术准备 VMwa ...
- 035. asp.netWeb用户控件之四通过用户控件实现投票和结果分析
用户控件Vote.ascx代码 <%@ Control Language="C#" AutoEventWireup="true" CodeFile=&qu ...
- C#List转字符串,字符串转List,字符数组转Int数组
List转字符串 [C#] 纯文本查看 复制代码 ? 01 02 List<string> List = new List<string>(); string strArray ...
- 各种数据分析图demo
极地蛛网图:http://www.hcharts.cn/demo/index.php?p=61 各种数据分析图demo: http://www.hcharts.cn/demo/index.php?p= ...
- 黄聪:WordPress: 使用 wp_insert_attachment 上传附件
我们来研究一下如何在主题或者插件的开发中上传附件: 主要参考这个函数:https://codex.wordpress.org/Function_Reference/wp_insert_attachme ...
- JAVA 几种引用类型学习
1.对象的强.软.弱和虚引用 在JDK 1.2以前的版本中,若一个对象不被任何变量引用,那么程序就无法再使用这个对象.也就是说,只有对象处于可触及(reachable)状态,程序才能使用它.从J ...
- volley_之基本使用
Volley的基本使用-------------- 本人初学,如有纰缪,望指正~ Volley是Google在2003年的I/O大会上推出的通信框架,结合了AsyncHttpClient和Univer ...
- 每天一个Linux命令
每天一个Linux命令(1):ls命令 每天一个Linux命令(2):cd命令 每天一个Linux命令(3):pwd命令 每天一个 Linux 命令(4):mkdir 每天一个 Linux 命令(5) ...
- 不同hadoop集群之间迁移hive数据
#!/bin/bash #set -x DB=$1 #获取hive表定义 ret=$(hive -e 'use ${DB};show tables;'|grep -v _es|grep -v _hb| ...