【问题标题】:How to convert Time Format PT1H55M0.000S or PT12H0M0.000Sto hh:mm:ss in xslt 1.0如何在 xslt 1.0 中将时间格式 PT1H55M0.000S 或 PT12H0M0.000S 转换为 hh:mm:ss
【发布时间】:2014-08-05 09:22:20
【问题描述】:

任何人都可以帮助我如何在 XSLT 1.0 中将此时间格式转换为 hh:mm:ss 吗?

示例 1:PT1H55M0.000S ---> 01:55:00

示例 2:PT12H0M0 ---> 12:00:00

【问题讨论】:

  • 为什么标题中的第二个示例与问题中的示例不同?

标签: xslt-1.0 time-format


【解决方案1】:

给定:

<xsl:variable name="input" select="'PT1H55M0.000S'" />

以下内容:

<output> 
    <xsl:value-of select="format-number(substring-before(substring-after($input, 'T'), 'H'), '00')"/>   
    <xsl:value-of select="format-number(substring-before(substring-after($input, 'H'), 'M'), ':00')"/>      
    <xsl:value-of select="format-number(substring-before(substring-after($input, 'M'), 'S'), ':00')"/>

</output> 

将导致:

<output>01:55:00</output>

注意:
这假设输入包含所有三个字符:H、M 和 S;否则它要复杂得多

【讨论】:

    猜你喜欢
    • 2015-10-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-12-30
    • 1970-01-01
    • 1970-01-01
    • 2011-06-17
    相关资源
    最近更新 更多