JSP page output date format with EL expression


JSP pages use EL expressions to output date format


1. Introduce tags in the header
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@taglib prefix ="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>

2. <fmt:formatDate value="${project.creatDate }" pattern="yyyy-MM-dd" />

First import the tag
<%@taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<input type="text" value="<fmt:formatDate value ="${viewKq.srq}" pattern="yyyy-Md" />"/>
value="${viewKq.srq}" EL expression takes the date value Pattern
: the output date format;
Formatting





Specific configuration:

<fmt:formatDate value="${isoDate}" type="both"/>
2004-5-31 23:59:59

<fmt:formatDate value="${date}" type="date"/>
2004-4-1

<fmt:formatDate value="${isoDate}" type="time"/>
23:59:59

<fmt:formatDate value="${isoDate}" type="date" dateStyle="default"/>
2004-5-31

<fmt:formatDate value="${isoDate}" type="date" dateStyle="short"/>
04-5-31

<fmt:formatDate value="${isoDate}" type="date" dateStyle="medium"/>
2004-5-31

<fmt:formatDate value="${isoDate}" type="date" dateStyle="long"/>
2004年5月31日

<fmt:formatDate value="${isoDate}" type="date" dateStyle="full"/>
2004年5月31日 星期一

<fmt:formatDate value="${isoDate}"type="time" timeStyle="default"/>
23:59:59

<fmt:formatDate value="${isoDate}" type="time" timeStyle="short"/>
下午11:59





















  M month number. Single-digit months without leading zeros.  
  MM month number. Single-digit months have a leading zero.  
  Abbreviated names of MMM months, as defined in AbbreviatedMonthNames.  
  MMMM The full name of the month, as defined in MonthNames.  
  y does not contain the year of the epoch. If the year without the epoch is less than 10, display the year without leading zeros.  
  yy The year that does not contain the epoch. If the year without the epoch is less than 10, display the year with leading zeros.  
  yyyy Four-digit year including the epoch.  
  gg period or era. This pattern is ignored if the date to be formatted does not have an associated period or era string.  
  h 12-hour hour. Single-digit hours without leading zeros.  
  hh Hour in 12-hour clock. Single-digit hours have leading zeros.  
  H 24-hour hour. Single-digit hours without leading zeros.  
  HH 24-hour hour. Single-digit hours have leading zeros.  
  m minutes. Single-digit minutes without leading zeros.  
  mm minutes. Single-digit minutes have a leading zero.  
  s seconds. Single-digit seconds without leading zeros.  
  ss seconds. Single-digit seconds have a leading zero.

<fmt:formatDate value="${xx}" pattern="dd/MM/yyyy HH:mm aa"/> and

<fmt:formatDate value="${xx}" pattern="dd/MM/yyyy hh:mm aa"/> The result displayed is different for 0 o'clock

h: hour, from 1 to 12, minutes am and pm range: 01 : 00 AM~12:59AMH: Hour, from 0 to 23 Range: 00:00 AM~23:59AM

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326239943&siteId=291194637