【问题标题】:Add time to current-time in BPEL process Oracle 10G在 BPEL 流程 Oracle 10G 中将时间添加到当前时间
【发布时间】:2014-04-29 20:12:03
【问题描述】:

您好,我有这个代码源

<from expression="concat(substring(xp20:current-dateTime(),1,(string-length(xp20:current-dateTime())-6)),'Z')"/>

这工作正常并返回这样的日期:

 2014-04-29T03:00:22Z

但我需要在日期上加上 10 秒,然后我试试这个:

 <from expression="concat(substring(xp20:add-dayTimeDuration-to-dateTime(xp20:current-dateTime(), 'PT10S'),1,(string-length(xp20:add-dayTimeDuration-to-dateTime(xp20:current-dateTime(), 'PT10S'))-6)),'Z')"/>

只有这个返回:

 Z

这适用于 Oracle BPEL 10G

有了这个

<from expression="concat(substring(string(xp20:add-dayTimeDuration-to-dateTime(xp20:current-dateTime(), 'PT10S')),1,(string-length(string(xp20:add-dayTimeDuration-to-dateTime(xp20:current-dateTime(), 'PT10S')))-6)),'Z')"/>

返回

Z

但是如果我只用 PT1M 更改 PT10S 就可以了

<from expression="concat(substring(string(xp20:add-dayTimeDuration-to-dateTime(xp20:current-dateTime(), 'PT1M')),1,(string-length(string(xp20:add-dayTimeDuration-to-dateTime(xp20:current-dateTime(), 'PT1M')))-6)),'Z')"/>

返回

2014-04-30T13:58:57Z

可能add-dayTimeDuration-to-dateTime忽略秒,用PT1M10S只加1M

【问题讨论】:

    标签: oracle xpath xquery soa bpel


    【解决方案1】:

    我无法针对 Oracle 进行测试,所以我不确定您的 XPath 中发生了什么,它基本上看起来是正确的。根据文档,Oracle 似乎支持format-dateTime。然后你就可以写得更简单更干净了

    xp20:format-dateTime(xp20:add-dayTimeDuration-to-dateTime(current-dateTime(), "PT10S"), "[Y0001]-[M01]-[D01]T[H01]:[m01]:[s01]Z")
    

    获得您想要实现的正确格式

    【讨论】:

    • 我测试并且编译说:“无法解析 xpath 函数“tokenize”,因为函数“tokenize”未注册” 和 dayTimeDuration 的同样问题......我不知道正确的命名空间,但是谢谢 :(
    • 我根据docs.oracle.com/cd/E11036_01/integrate.1013/b28981/…的文档更新了我的答案,我希望它反映了 Oracle 支持的内容。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-11-07
    • 2010-10-10
    • 1970-01-01
    相关资源
    最近更新 更多