2014年5月17日星期六

Beg ah timestamp on jsp page how to convert to yyyy-MM-dd HH: mm: ss

Thanks for the great God who database mysql, java language jsp page
------ Solution -------------- ------------------------------
formatted date .

SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss") 
String dateStr = sdf.format(date);

------ Solution ------------------------------------- -------
	Long time= System.currentTimeMillis();
//Long time= 1400038220l;
        Date date= new Date(time);  
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");  
        String dateString = sdf.format(date);  
        System.out.println(dateString); 

------ For reference only ------------------------- --------------
tag
------ For reference only ---------------------------------------
1, if using js words , Get on the date according to the date when the minutes and seconds , respectively , for string stitching, and then displayed on the page ;
2, jsp inside a block of code with java , then that is a floor to say, the date format
------ For reference only ---------------- -----------------------

------ For reference only ------------------- --------------------

upstairs positive solutions , JSP date formatting tags !
------ For reference only -------------------------------------- -
jstl

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

<fmt:formatDate value="${time}" pattern="yyyy-MM-dd HH:mm:ss"/>   

------ For reference only ----------------------------------- ----


This I also think again turn back , but the object inside is long time attribute type is converted String ah how I put this object inside it
- ----- For reference only ---------------------------------------


$ {time} type can be long do
------ For reference only ------------------------ ---------------
learn, learn. . .
------ For reference only -------------------------------------- -

  
$ {time} you can be long type  

so to speak 1400038220 This timestamp can be converted directly into the page yyyy-MM-dd HH: mm: ss
------ For reference only ---------- -----------------------------


so to speak 1400038220 This timestamp can be converted directly into the page yyyy-MM-dd HH: mm: ss
------ For reference only --------- ------------------------------

+1
------ For reference only ---------------------------------------
your date right now .

long sysTime = System.currentTimeMillis();  
System.out.println(sysTime);
####1400038973111


------ For reference only ----------------------------------- ----

    
$ {time} you can be long type          
  
so to speak 1400038220 This timestamp can be converted directly into the page yyyy-MM-dd HH: mm: ss  
This can not be right, it should only be a date type
------ For reference only ----------------------- ----------------

great God you said I replaced 1400040030898 normal time but the page newspaper print exceptions are:
 javax.servlet.jsp.JspException: In < parseDate >, value attribute can not be parsed: " ; 1400040030898 "  
at org.apache.taglibs.standard.tag.common.fmt.ParseDateSupport.doEndTag (ParseDateSupport.java: 189)
at org.apache.jsp.pages.webuser.apiRegistationList_jsp._jspx_meth_fmt_005fparseDate_005f0 (apiRegistationList_jsp.java: 1095)

------ For reference only ---------------------------------- -----

      
$ {time} you can be long type                
    
so to speak 1400038220 This timestamp can be converted directly into the page yyyy-MM-dd HH: mm: ss          
This can not be right, it should only be a date type  
If I use this tag does

------ For reference only ---------------------------------- -----

If my time java actually was a long turn ah my great God that ye
------ For reference only ---------------------------------------
you do not know how to engage in jsp tag well you better turn back
------ For reference only ------------------------------- --------

  
so to speak 1400038220 This timestamp can be converted directly into the page yyyy-MM-dd HH: mm: ss  

Reference , 14th Floor

------ For reference only ---------------------------------- -----





;

$ {apiRegistation.apiDatetime} timestamp from backstage pass over such is 1400040030898
------ For reference only ---------------- -----------------------

    
so to speak 1400038220 This timestamp can be converted directly into the page yyyy-MM-dd HH: mm: ss          
  
Reference , 14th Floor   
 
Brother, I turn for the better in the future how it spread to the check out page displays a list but used the display: Output jsp page table are as follows :




;



------ For reference only --------------------- ------------------
Date.prototype.format = function (format)
{
var o = {
"M +": this.getMonth () +1, / / ​​month
"d +": this.getDate (), / / ​​day
"h +": this.getHours (), / / ​​hour
"m +": this.getMinutes (), / / ​​minute
"s +": this.getSeconds (), / / ​​second
"q +": Math.floor ((this.getMonth () +3) / 3), / / ​​quarter
"S": this.getMilliseconds () / / millisecond
}
if (/ (y +) /. test (format)) format = format.replace (RegExp. $ 1, .
(this.getFullYear () + "") substr (4 - RegExp $ 1.length.));
for (var k in o) if (new RegExp ("(" + k + ")"). test ( format))
format = format.replace (RegExp. $ 1,
RegExp $ 1.length == 1 o [k].?:
("00" + o [k]) substr (("" + o [k]) length.)).;
return format;
}




var unixTimestamp = new Date (value);
return unixTimestamp.format ('yyyy-MM-dd');
------ For reference only --------------------- ------------------

cousin I could not understand ,
------ For reference only ----- ----------------------------------

cousin I could not read,  

write a javascript method
function (value) {
var unixTimestamp = new Date (value);
return unixTimestamp.format ('yyyy-MM-dd');
}
Take your date to wear in, what is called , returns the output is formatted date format
------ For reference only ---- -----------------------------------
floor positive solution. . . . .
------ For reference only -------------------------------------- -


the first floor is a positive solution , but different in my case ah String dateStr = sdf.format (date); him this last is how I put String object inside it there is a long object type
------ For reference only --------------------------------- ------

support.
------ For reference only -------------------------------------- -
    
------ For reference only ---------------------------------- -----

support.  
This time seems to be the type of my date was long reported anomaly javax.el.ELException: Cannot convert 1,400,040,030,898 of type class java.lang. Long to class java.util.Date
at org.apache.el.lang.ELSupport.coerceToType (ELSupport.java: 420)
------ For reference only -------------- -------------------------
solved thank the great God who reply Thanks a result of this source code is correct of







No matter what type of direct use of these words
where property = "apiDatetime" in apiDatetime is long format type directly on the object inside me how to give you points ah
------ For reference only ---------------------------------------


This display is where you define the label ?

没有评论:

发表评论