jstl之fmt

<%@ page language="java" contentType="text/html; charset=UTF-8"
	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"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>fmt:formatDate</title>
</head>
<body>
	<h3>Number Format:</h3>
	<c:set var="now" value="<%=new java.util.Date()%>" />

	<p>
		Formatted Date (1):
		<fmt:formatDate type="time" value="${now}" />
	</p>
	<p>
		Formatted Date (2):
		<fmt:formatDate type="date" value="${now}" />
	</p>
	<p>
		Formatted Date (3):
		<fmt:formatDate type="both" value="${now}" />
	</p>
	<p>
		Formatted Date (4):
		<fmt:formatDate type="both" dateStyle="short" timeStyle="short"
			value="${now}" />
	</p>
	<p>
		Formatted Date (5):
		<fmt:formatDate type="both" dateStyle="medium" timeStyle="medium"
			value="${now}" />
	</p>
	<p>
		Formatted Date (6):
		<fmt:formatDate type="both" dateStyle="long" timeStyle="long"
			value="${now}" />
	</p>
	<p>
		Formatted Date (7):
		<fmt:formatDate pattern="yyyy-MM-dd" value="${now}" />
	</p>

</body>
</html>


<%@ page language="java" contentType="text/html; charset=UTF-8"
	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"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>fmt:formatNumber</title>
</head>
<body>
	<h3>Number Format:</h3>
	<c:set var="balance" value="120000.2309" />
	<c:out value="${balance }"></c:out>
	<p>
		Formatted Number (1):
		<fmt:formatNumber value="${balance}" type="currency" />
	</p>
	<p>
		Formatted Number (2):
		<fmt:formatNumber type="number" maxIntegerDigits="3"
			value="${balance}" />
	</p>
	<p>
		Formatted Number (3):
		<fmt:formatNumber type="number" maxFractionDigits="3"
			value="${balance}" />
	</p>
	<p>
		Formatted Number (4):
		<fmt:formatNumber type="number" groupingUsed="false"
			value="${balance}" />
	</p>
	<p>
		Formatted Number (5):
		<fmt:formatNumber type="percent" maxIntegerDigits="3"
			value="${balance}" />
	</p>
	<p>
		Formatted Number (6):
		<fmt:formatNumber type="percent" minFractionDigits="10"
			value="${balance}" />
	</p>
	<p>
		Formatted Number (7):
		<fmt:formatNumber type="percent" maxIntegerDigits="3"
			value="${balance}" />
	</p>
	<p>
		Formatted Number (8):
		<fmt:formatNumber type="number" pattern="###.###E0" value="${balance}" />
	</p>
	<p>
		Currency in USA :
		<fmt:setLocale value="en_US" />
		<fmt:formatNumber value="${balance}" type="currency" />
	</p>
</body>
</html>

<%@ page language="java" contentType="text/html; charset=UTF-8"
	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"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>fmt:parseDate</title>
</head>
<body>
	<h3>Date Parsing:</h3>
	<c:set var="now" value="20-10-2010" />

	<fmt:parseDate value="${now}" var="parsedEmpDate" pattern="dd-MM-yyyy" />
	<p>
		Parsed Date:
		<c:out value="${parsedEmpDate}" />
	</p>
</body>
</html>

<%@ page language="java" contentType="text/html; charset=UTF-8"
	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"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>fmt:parseNumber</title>
</head>
<body>
	<h3>Number Parsing:</h3>
	<c:set var="balance" value="1250003.350" />

	<fmt:parseNumber var="i" type="number" value="${balance}" />
	<p>
		Parsed Number (1) :
		<c:out value="${i}" />
	</p>
	<fmt:parseNumber var="i" integerOnly="true" type="number"
		value="${balance}" />
	<p>
		Parsed Number (2) :
		<c:out value="${i}" />
	</p>
</body>
</html>


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值