Formatting JSP page time type

Source: Internet
Author: User

The time type output of the JSP page often needs to be formatted, either not the desired format or the page display has such problems, such as: yyyy-mm-dd hh: mm: there is a case with 0 in the SS. In the above cases, two formats of page time output are provided:

1. C: formatting time in foreach

Introduction

<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>

Use

<FMT: formatdate value = "$ {date}" pattern = "mm DD, yyyy hh: mm: SS"/>

For example:

<C: forEach items = "$ {page. result} "var =" task "> <div class =" $ {task. extend. statusStyle} "> <div class =" $ {task. extend. statusStyle} up "> <div class =" $ {task. extend. statusStyle} upleft "> <span class =" face ">  </span> </div> <div class = "$ {task. extend. statusStyle} upright "style =" width: 800px; "> <div class =" title "> <a href =" javascript: showDetail ($ {task. id}) "> $ {Task. title} <span class = "settime"> (<fmt: formatDate value = "$ {task. createDate} "pattern =" yyyy-MM-dd HH: mm: ss "/>) </span> </a> </div> <! -- <Div class = "w270_guanzhu"> <div class = "task_an"> <span onclick = "attent ('$ {task. id} ', '0') "style =" cursor: pointer; "> no longer follow </span> </div> --> </div> <div class =" $ {task. extend. statusStyle} down "> <div class =" $ {task. extend. statusStyle} down_left "> <span> remaining <B >$ {task. extend. surplusDay} </B> day </span> <div class = "bfpix"> <div class = "pix" style = "width :$ {task. finishedRate} px; "> </div> <div class =" pixfont ">$ {task. finishedRate }%</div> <div class = "$ {task. extend. statusStyle} down_right "> <ul> <li style =" border: 0px; "> </li> <p >$ {task. subTaskCount }</p> <span> subtask </span> </li> <p >$ {task. extend. scheduleCount }</p> <span> schedule </span> </li> <p >$ {task. extend. taskLogCount }</p> <span> dynamic </span> </li> <p> 0 </p> <span> document </span> </li> </ul> </div> </c: forEach>

2. Format time in S: iterator:

You do not need to introduce anything separately, for example:

<S: iterator value = "# request. page. result "id =" log "> <div class =" taskinfo_schedule "> <div class =" face left "> <span>  </span> </div> <div class = "detail left"> <p> <B> <s: property value = "# log. createName "/> </B>: </p> <em>" </em> <s: property value = "# log. content "/> <em>" </em> <span class = "settime"> (<s: date name = "# log. createDate "format =" yyyy-MM-dd HH: mm: ss "/>) </span> </p> </div> </s: iterator>

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.