Gopalan Suresh Raj's Web Cornucopia
An Oasis for the parched Enterprise Services Engineer/Developer

    WS-BPEL-Specifying Dates, Times, and duration

    WS-BPEL

    In XML Schema, the duration datatype is used to represent durations of time (e.g., to represent – for 19 years 10 months and 28 days, or, for 10 hours 37 minutes and 46 seconds) which can be thought of as time intervals. Similarly, the datetime and date datatypes in XML Schema, are used to reference specific instances of time (e.g., to represent – the 28th day of the 10th month of the year 2008 or time such as 10:28:19am).

    Whatever the query language used (XPath 1.0 being the default) by the BPEL Engine, the date or time expressions used in a query have to evaluate to a valid value corresponding to a duration, date or datetime datatype as defined in the XML Schema specification. All the three XML Schema datatypes use the ISO 8601 standard that uses characters appended to numbers within the date and time information. You can read more about this here from the source. I will try to make it more understandable here in this blog entry.

    Specifying a duration:

    Time durations are specified in the format:

    PnYnMnDTnHnMnS
    

    where,

    • P – is a required character that represents period, the duration designator. All duration expressions always start with a P
    • Y – is the year designator. For example, to indicate 19 years, you’d use19Y
    • M – is the month designator. For example, to indicate 10 years, you’d use10M
    • D – is the days designator. For example, to indicate 28 days, you’d use 28D
    • T – is an optional character that indicates the start of the time duration
    • H – is the hour designator. For example, to indicate 10 hours, you’d use10H
    • M – is the minute designator. For example, to indicate 37 minutes, you’d use 37M
    • S – is the seconds designator. For example, to indicate 46 seconds, you’d use 46S

    duration samples:

    So to specify a duration of 19 years, 10 months, 28 days, 10 hours, 37 minutes, and 46 seconds, the duration expression would look like P19Y10M28DT10H37M46S. If you want to use it in a BPEL ____ activity, it would read:

    <wait for=”‘P19Y10M28DT10H37M46S’“/>
    

    which means wait for a duration of 19 years, 10 months, 28 days, 10 hours, 37 minutes, and 46 seconds.

    Similarly, to specify a duration of 1 year, 2 months, and 3 days, the duration expression would look like P1Y2M3D. If you want to use it in a BPEL activity, it would read:

    <wait for=”‘P1Y2M3D’“/>
    

    which means wait for a duration of 1 year, 2 months, and 3 days.

    Similarly, to specify a duration of 1 hour, and 2 minutes, the duration expression would look like PT1H2M. If you want to use it in a BPEL ____ activity, it would read:

    <wait for=”‘PT1H2M’“/>
    

    which means wait for a duration of 1 hour, and 2 minutes.

    Specifying date and time:

    Specific date and time references have the form:

    CCYY-MM-DDThh:mm:ss
    

    where,

    • CC – is the century designator, specified as 2 or more digits. Valid range from 00 to …
    • YY – is the year designator, specified as 2 digits. Valid range from 00 to 99.
    • MM – is the month designator, specified as 2 digits. Valid range from 01 to 12.
    • DD – is the day designator, specified as 2 digits. Valid range from 01 to 31.
    • T – indicates the start of the time designator.
    • hh – is the hour designator, specified as 2 digits. Valid range from 00 to 23.
    • mm – is the minute designator, specified as 2 digits. Valid range from 00 to 59.
    • ss – is the seconds designator, specified as 2 digits with an optional decimal value allowed of the form ss.ssss to increase precision. Valid range from 00 to 59.
    • z – is the optional Coordinated Universal Time (UTC). If present, it should immediately follow the time element. To specify an offset from the UTC time, append a positive(+) or negative(–) time to the datetime value of the form hh:mm.

    datetime samples:

    So, to specify 10:28:19am, 28th October 2008, the datetime expression would look like 2008-10-28T10:28:19. If you want to use it in a BPEL ____ activity, it would read:

    <wait until=”‘2008-10-28T10:28:19’“/>
    

    which means wait until the deadline 10:28:19am, 28th October 2008.

    Similarly, to specify 07:30:00pm, the datetime expression would look like 19:30:00. If you want to use it in a BPEL ____ activity, it would read:

    <wait until=”’19:30:00′“/>
    

    which means wait until the deadline 07:30:00pm.

    UTC datetime samples:

    Similarly, to specify 10:28:19am in UTC, the datetime expression would look like 10:28:19z. If you want to use it in a BPEL ____ activity, it would read:

    <wait until=”’10:28:19z’“/>
    

    which means wait until the deadline 10:28:19am, in UTC.

    Similarly, if the UTC time was 6:30:19pm 28th October 2008, to specify 10:30:19am, 28th October 2008 California time (Pacific Standard Time which is UTC-08:00), the datetime expression would look like 2008-10-28T18:30:19-08:00. If you want to use it in a BPEL activity, it would read:

    <wait until=”‘2008-10-28T18:30:19-08:00’“/>
    

    which means wait until the deadline 10:30:19am, 28th October 2008 California time(Pacific Standard Time).

    Similarly, if the UTC time was 10:00:19am 28th October 2008, to specify 03:30:19pm, 28th October 2008 Indian Standard time (which is UTC+05:30), the datetime expression would look like 2008-10-28T10:00:19+05:30. If you want to use it in a BPEL activity, it would read:

    <wait until=”‘2008-10-28T10:00:19+05:30’“/>
    

    which means wait until the deadline 03:30:19pm, 28th October 2008 Indian standard time.

    Author Bibliography

    Gopalan Suresh Raj is a Senior Analyst, Software Architect, and Developer with expertise in multi-tiered systems development, enterprise service architectures, and distributed computing. He is also an active author, including contributions to Professional JMS Programming, Wrox Press, 2001, Enterprise Java Computing-Applications and Architecture, Cambridge University Press, 1999, and The Awesome Power of JavaBeans, Manning Publications Co., 1998. He has submitted papers at international fora, and his work has been published in numerous technical journals. Visit him at his Web Cornucopia© site (webcornucopia.com) or mail him at gopalan@webcornucopia.com.

    Back