<%@ page language="java" contentType="text/html; charset=GB18030"
pageEncoding="GB18030"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="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=GB18030">
<title>Insert title here</title>
</head>
<body>
<h1>测试格式化日期标签</h1>
today(default):<fmt:formatDate value="${today}"/><br>
today(type="date"):<fmt:formatDate value="${today}" type="date"/><br>
today(type="time"):<fmt:formatDate value="${today}" type="time"/><br>
today(type="both"):<fmt:formatDate value="${today}" type="both"/><br>
today(dateStyle="short"):<fmt:formatDate value="${today}" dateStyle="short"/><br>
today(dateStyle="medium"):<fmt:formatDate value="${today}" dateStyle="medium"/><br>
today(dateStyle="long"):<fmt:formatDate value="${today}" dateStyle="long"/><br>
today(dateStyle="full"):<fmt:formatDate value="${today}" dateStyle="full"/><br>
today(type="both" dateStyle="full" timeStyle="full"):<fmt:formatDate value="${today}" type="both" dateStyle="full" timeStyle="full"/><br>
today(pattern="yyyy/MM/dd HH:mm:ss"):<fmt:formatDate value="${today}" pattern="yyyy/MM/dd HH:mm:ss" var="v" scope="page"/><br>
${v }
<h1>测试格式化数字标签</h1>
n(default):<fmt:formatNumber value="${n}" ></fmt:formatNumber><br>
n(pattern=""###,###,###,###.####"):<fmt:formatNumber value="${n}" pattern="###,###,###,###.####" ></fmt:formatNumber><br>
n(pattern=""###,###,###,###.0000"):<fmt:formatNumber value="${n}" pattern="###,###,###,###.0000" ></fmt:formatNumber><br>
n(groupingUsed="false"):<fmt:formatNumber value="${n}" groupingUsed="false" ></fmt:formatNumber><br>
n(maxFractionDigits="15" minFractionDigits="10"):
<fmt:formatNumber value="${n}" maxFractionDigits="15" minFractionDigits="10" ></fmt:formatNumber><br>
n(minIntegerDigits="15" axIntegerDigits="10"):
<fmt:formatNumber value="${n}" minIntegerDigits="15" maxIntegerDigits="10" ></fmt:formatNumber><br>
n(typ="currency"):<fmt:formatNumber value="${n}" type="currency" ></fmt:formatNumber><br>
n(typ="currency" currencySymbol="$"):<fmt:formatNumber value="${n}" type="currency" currencySymbol="$" ></fmt:formatNumber><br>
p(type="percent"):<fmt:formatNumber value="${p}" type="percent" minFractionDigits="2" maxFractionDigits="2"></fmt:formatNumber><br>
</body>
</html>
jstl_fmt
最新推荐文章于 2023-04-10 15:54:20 发布
本文介绍如何使用JSP中的JSTL标签库来格式化日期与数字。通过不同的属性设置,如type、dateStyle、timeStyle及pattern等,可以实现日期和时间的不同展示形式;对于数字,则可以通过pattern、type等属性进行格式调整。
3783

被折叠的 条评论
为什么被折叠?



