如何在JSP中格式化日期?
<FMT:formatDate>标记用于格式的日期在一个多种方式。
属性
<FMT:formatDate>标签具有以下属性-
pattern属性用于指定日期的更精确处理-
示例
<%@ 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>JSTL fmt:dateNumber Tag</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>上面的代码将产生以下结果-
Date Format: Formatted Date (1): 14:27:18 Formatted Date (2): 23-Sep-2010 Formatted Date (3): 23-Sep-2010 14:27:18 Formatted Date (4): 23/09/10 14:27 Formatted Date (5): 23-Sep-2010 14:27:18 Formatted Date (6): 23 September 2010 14:27:18 GST Formatted Date (7): 2010-09-23
热门推荐
1 训练狗狗工作
4 狗狗定点排便训练
5 狗狗训练吠叫
6 狗狗尿垫训练
7 狗狗训练座
8 狗狗训练攻略
9 狗狗训练记
10 做训练狗狗
11 狗狗训练词
12 狗狗谢谢怎么训练
13 狗狗训练如厕
14 狗狗太凶怎么训练
15 狗狗训练它
16 狗狗克制训练
17 训练基地狗狗
18 怎么样训练狗狗大小硬