开发者

parsing date and time

开发者 https://www.devze.com 2023-01-06 17:06 出处:网络
CurrentlyIn 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

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

0

精彩评论

暂无评论...
验证码 换一张
取 消