Page last modified 08:50, 29 May 2018 by villes

.toDate() Redirected from User Guides/myXML/5: OCL Rules/Available methods for OCL base types/.toDate()

    Table of contents

    Description of the method

     

    Description:

    .toDate() method converts a string to date. After converting to date, the date methods are available.

    The following format is expected for the string to be able to convert it to date: YYYYMMDD e.g. 25st of January 2015 would be "20150125". If you want to convert e.g. integer field to a date you first need to convert the integer to string and after that convert it to date e.g. element.toString().toDate().

    Available for: string
    Parameters:  -
    Return type: date

    Example

     

    Context: HeaderType1
    OCL:
    self.InstrId.size() = 35 implies (
        let s1 : string = self.InstrId.substring(0,4)
        in
        let s2 : string = self.InstrId.substring(4,6)
        in
        let s3 : string = self.InstrId.substring(6,8)
        in
        let sAll : string = s1+"-"+s2+"-"+s3
        in (
            sAll.toDate().allowedDaysInFuture(2) and
            sAll.toDate().allowedDaysInPast(2)
            )
        )
    Description: The example rule converts <Id> element value to a date and checks that the date is within 2 days into future or past

     

    Assuming current date is 2018-05-22, the XML snippet below would pass this check.

    <InstrId>2018052312345678901BRRRR00000000001</InstrId>

    The other snippet below however would not pass this check.

    <InstrId>2017052312345678901BRRRR00000000001</InstrId>

    Menu