The page in the help of Brother Zhou finished immediately, let the chief looked under, there are two problems need to be modified, I summed up the following:
1. Change the date of the CST format to yyyy-mm-ddd similar to this.
2. For example, from the database to find out the size of the file is 4500, we need to display in the front of how many KB or how many m.
My ideas for solving the problem are as follows:
1. The FILETIME format from the database through the mapper map makes us want 2015-07-21 14:29:32 like this, but it's the time to put it in the back of the list into the Thu Jul 10:55:42 CST 2015 this CST format date.
I think, through the method of date conversion, the former from the latter, and then into the list inside. The code is as follows:
1 Date fileTime = coursedatalist.get (0). Getfiletime (); 2 Get date from background (CST format) 3 simpledateformat sdf = SimpleDateFormat ("EEE MMM dd HH:mm:ss zzz yyyy" 4 New a SimpleDateFormat object and specifies the object format type. 5 String stringdate = new SimpleDateFormat ("Yyyy-mm-dd HH:mm:ss" ). Format (fileTime); 6 Parser, convert the FILETIME to the date we want to format. At this point stringdate is the date format we need.
But then you can't find the method how to get this string type of stringdate to replace the date type data in the list and make it appear in the front end. Sadness ~ ~, later thought that since the background conversion encountered trouble, can try on the front. Then I consulted another colleague. He has just met the problem.
The workaround is this:
Introduce this tag library on the JSP page:
1 <% @ taglib URI = " http://java.sun.com/jsp/jstl/fmt " prefix = " FMT " %>
And then, when you get this time:
1 < TD >< value= "${file.filetime}" pattern= "Yyyy-mm-dd hh:mm"/> </td>
So easy.
http://dengzh.iteye.com/blog/525966 for the FMT label. For yourself to study with everyone.
The second question is: If the file size is displayed in KB or m on the page through the statement, the following is the code:
1 <c:ifTest= "${file.filesize < ' 1024x768 '}">${file.filesize}kb</c:if>2 <c:ifTest= "${file.filesize > ' 1024x768 '}"><Fmt:formatnumbertype= "Number"value= "${file.filesize/1024}"maxfractiondigits= "2"/>M</c:if>
07/30/15 codeing Problems encountered