07/30/15 codeing Problems encountered

Source: Internet
Author: User
Tags filetime

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

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.