Skip to content

Instantly share code, notes, and snippets.

@yongboy
Created May 21, 2011 10:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yongboy/984412 to your computer and use it in GitHub Desktop.
Save yongboy/984412 to your computer and use it in GitHub Desktop.
jstl format test
<%@ 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