Created
May 21, 2011 10:09
-
-
Save yongboy/984412 to your computer and use it in GitHub Desktop.
jstl format test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<%@ page language="java" contentType="text/html; charset=GBK" | |
pageEncoding="GBK"%> | |
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> | |
<%@ taglib prefix="f" uri="http://java.sun.com/jsp/jstl/fmt"%> | |
<% | |
String date = "2011-05-21 18:20:32.0"; | |
request.setAttribute("dateStr", date); | |
request.setAttribute("nowDate", new java.util.Date()); | |
%> | |
<!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=GBK"> | |
<title>date format test</title> | |
</head> | |
<body> | |
now date: | |
<br /> | |
<f:formatDate value="${nowDate}" pattern="yyyy-MM-dd HH:mm" /> | |
<br /> | |
ori date : ${dateStr} | |
<br /> | |
<f:parseDate var="tmpDate" value="${dateStr}" | |
pattern="yyyy-MM-dd HH:mm:ss" /> | |
curr date : | |
<f:formatDate value="${tmpDate}" pattern="yyyy-MM-dd HH:mm" /> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment