parsing date and time
Currently In my source file, i am getting date and time values like below. 2010-07-06T19:06:47
i want to 开发者_运维百科put date in one variable and time in another one. Please let me know how to do this.
Assuming the combined date/time value is in variable $date-time
...
<xsl:variable name="date" select="substring-before($date-time, 'T')"/>
<xsl:variable name="time" select="substring-after($date-time, 'T')"/>
The quickest and easiest way to do this would be to split/explode the variable into 2 pieces with the date in one and the time in the other.
Date Parsing means converting String into Date. Same Simple DateFormat codes are used to parsing date.
For example,
DateFormat formatter = new SimpleDateFormat("MM/dd/yy");<br/>
Date date = (Date)formatter.parse("07/16/87");<br/>
formatter = new SimpleDateFormat("dd-MMM-yy");<br/>
date = (Date)formatter.parse("16-Jul-87");<br/>
Source : Tutorial Data - Date and Time
精彩评论