kiran puram
kiran puram

Reputation: 9

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.

Upvotes: 0

Views: 310

Answers (3)

Ash Khote
Ash Khote

Reputation: 1

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

Upvotes: 0

Pavel Minaev
Pavel Minaev

Reputation: 101595

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')"/>

Upvotes: 1

Randy Cleary
Randy Cleary

Reputation: 725

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.

Upvotes: 0

Related Questions