Skip to Main Content

DevOps, CI/CD and Automation

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How to convert xs:date to xs:dateTime

James.TranJun 23 2015 — edited Jun 25 2015

In my application, there are the following 2 cases I need to handle:

  1. I have a "xs:date" and I need to convert it to "xs:dateTime"
  2. I have a "xs:date" and a "xs:time" and I need to combine them into "xs:dateTime"

Following the answer for this question on Stackoverflow, I tried both "xs:dateTime($date)" and  "fn:dateTime($date, $time)" but none of them worked.

When I used "xs:dateTime($date)" to handle the 1st case, I got the following exception when OSB reaches the conversion step for the date:

OSB Replace action failed updating variable "body": Error parsing XML: {err}XP0021: "2014-12-09": can not cast to {http://www.w3.org/2001/XMLSchema}dateTime: error: date: Invalid date value: wrong type: 2014-12-09

When I used "fn:dateTime($date, $time)", the transformation is not even accepted by the IDE. It displays the following error:

line 113, column 42: "{http://www.w3.org/2004/07/xpath-functions}dateTime" unknown function (or number of arguments (2) is wrong

At the moment, as a workaround, I am using "concat" to combine the date and time fields in the 2nd case and to append "T00:00:00" to handle the 1st case but I feel this is not a good approach.

I'd be very grateful if you could show me how I can properly convert date fields into dateTime format.

This post has been answered by odie_63 on Jun 25 2015
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jul 23 2015
Added on Jun 23 2015
9 comments
19,823 views