JSTL之数字、日期格式化
来源:互联网 发布:雪利酒 知乎 编辑:程序博客网 时间:2024/05/29 08:36
java格式化输出:
DecimalFormat df = new DecimalFormat("格式");
String fmt =df.format(double);
符号
0
#
.
,
-
%
其他任何符号
===============================================================================
1.
<%@ page pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<html>
<head>
<title>Date Formatting</title>
</head>
<body>
<h1>时间货币格式化</h1>
----à那个货币的符号和当前web服务器的 local 设定有关
</body>
</html>
显示结果:
时间货币格式化
$12.00
$12.0
¥12.00
12.00元
¥12.00
123456.79
123,456.79
.79
12.34%
1,200%
1200.00%
120.00‰
2.格式化日期
类似于数字和货币格式化,本地化环境还会影响生成日期和时间的方式。
<fmt:formatDate>动作的属性
type: 可以是time,date或both。控制是否只生成时间,只生成日期,或者时间日期都生成。
dateStyle: 可以是short, medium, long 或 full(default)。控制打印日期使用的具体格式。
timeStyle: 可以是short, medium, long 或 full(default)。控制打印时间使用的具体格式。
value: 这是一个java.util.Date 类型的值,用于生成日期和时间。
<%@ page pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<html>
<head>
<title>Date Formatting</title>
</head>
<body>
<h1>时间格式化</h1>
<fmt:timeZone value="EST">
</fmt:timeZone>
</body>
</html>
显示结果:
时间格式化
2011-8-23 2:13:03
2011-8-23
2:13:03
2011-8-23
11-8-23
2011-8-23
2011年8月23日
2011年8月23日 星期二
2:13:03
上午2:13
2:13:03
上午02时13分03秒
上午02时13分03秒 EST
星期二, 八月 23, 2011 02:13:03 -0500
23 八月 11, 2:13:3 上午 东部标准时间
- JSTL之数字、日期格式化---、
- JSTL之数字、日期格式化
- JSTL之数字、日期格式化
- JSTL之数字、日期格式化---(转载)
- JSTL fmt数字日期格式化
- Jstl数字日期格式化标签
- JSTL之数字、日期格式化<fmt:formatNumber/>、<fmt:formatDate/>
- JSTL I18N格式标签库之----数字日期格式化
- JSTL之数字、日期格式化<fmt:formatNumber/>、<fmt:formatDate/>
- JSTL之数字、日期格式化<fmt:formatNumber/>、<fmt:formatDate/>
- JSTL之数字、日期格式化<fmt:formatNumber/>、<fmt:formatDate/>
- JSTL标签库数字,日期格式化
- JSTL fmt:formatNumber日期、 数字、货币格式化
- JSTL fmt:formatNumber日期、 数字、货币格式化
- JSTL fmtformatNumber日期、 数字、货币格式化
- JSTL fmt:formatNumber日期、 数字、货币格式化
- JSTL fmt:formatNumber日期、 数字、货币格式化
- JSTL fmtformatNumber日期、 数字、货币格式化
- 关于Java 项目的思考总结
- java+内存分配及变量存储位置的区别
- Android--View的工作流程
- spark--使用parallelize方法创建RDD
- 站在VR世界的大门前
- JSTL之数字、日期格式化
- Python--弹性分布式数据集(RDD)
- 1009. 说反话 (20)
- MFC学习之路
- 第五周:[Leetcode]121. Best Time to Buy and Sell Stock
- 解决ORA-21561: OID generation failed
- 将Hive启动为服务
- makefile的粗浅理解
- Android版本概览