I am not sure why the following code works: str
is a date in the format 2011-11-04 15:54:48.38
. It is a string. When executing the following code:
<fmt:parseDate var="xxx" type="date" pattern="y-M-d H:m:s" value="${str}" />
xxx: <c:out value="${xxx}"></c:out><br />
xxx.time: <c:out value="${xxx.time}"></c:out><br />
str.time: <c:out value="${str.time}"></c:out><br />
str: <c:out value="${str}"></c:out><br />
I get this output
xxx: Fri Nov 04 15:54:48 GMT 2011
xxx.time: 1320422088038
str.time: 1320422088380
str: 2011-11-04 15:54:48.38
How is that possible? Is there any automatic conversion in place for the str.time
value? How do these conversions work?
You are getting that output because the "getTime()" of a Date object returns the number of milliseconds since January 1, 1970, 00:00:00 GMT represented by the Date object.
Edit:
Use: http://www.epochconverter.com/
And put in the seconds outputs, you'll see it corresponds back to your dates.
I think you're not running the code you think you're running. This one should definitely throw a PropertyNotFoundException
on ${str.time}
. To naildown it, add the following line to find out what ${str}
actually is.
<c:out value="${str.class.name}" />
It's apparently a class which prints the given string format on toString()
and has a getTime()
method.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.