<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<jsp:useBean id="now" class="java.util.Date"/>
<fmt:setLocale value="en_US"/>
<fmt:setLocale value="zh_CN"/>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>My JSP starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
</head>
<body bgcolor="#ffffff">
<h3>国际化标签使用</h3>
<fmt:setBundle var="message" basename="message" />
<fmt:bundle basename="allMessage">
<fmt:message key="userName"/><br/>
<fmt:message key="password" bundle="${message}"/>
</fmt:bundle>
<hr>
现在的时间是:<br/>
<!-- 用于格式化输出时间GMT(格林尼治标准时间) -->
<fmt:timeZone value="Asia/Hong_Kong">
<fmt:formatDate value="${now}" type="both" dateStyle="full" timeStyle="full"/>
</fmt:timeZone>
<hr>
<fmt:formatNumber value="1000.888" type="currency" var="money"/>
${money}<br>
<fmt:formatNumber value="123456.789" pattern="$#,###.##" var="number"/>
${number}<br>
<fmt:formatNumber value="0.12" type="percent" var="percent"/>
${percent}<br>
<hr>
<fmt:parseNumber value="12%" type="percent" var="percent" />
${percent}<br>
<fmt:parseNumber value="$123,456.79" pattern="$#,###.##" var="number"/>
${number}
<hr>
<fmt:formatDate value="${now}" type="both" /><br>
<fmt:formatDate value="${now}" type="both" pattern="yyyy年MM月dd日 EEEE HH时mm分ss秒"/><br>
<fmt:formatDate value="${now}" type="date" /><br>
<fmt:formatDate value="${now}" type="time" /><br>
<fmt:formatDate value="${now}" type="time" timeZone="GMT"/><br>
<fmt:formatDate value="${now}" type="both" dateStyle="default" /><br>
<fmt:formatDate value="${now}" type="both" pattern="EEEE, MMMM dd, yyyy HH:mm:ss Z" />
<hr>
<fmt:parseDate value="2010年06月04日 星期五 15时24分57秒" type="both" pattern="yyyy年MM月dd日 EEEE HH时mm分ss秒" var="ttt"/>
${ttt}
</body>
</html>
转载于:https://my.oschina.net/u/139546/blog/374111