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

.toDate() Redirected from User Guides/User guide for OCL rules in XMLdation environment/Available methods for OCL base types/.toDate()

    Table of contents

    Description of the method



    .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



    Context: HeaderType1
    self.InstrId.size() = 35 implies (
        let s1 : string = self.InstrId.substring(0,4)
        let s2 : string = self.InstrId.substring(4,6)
        let s3 : string = self.InstrId.substring(6,8)
        let sAll : string = s1+"-"+s2+"-"+s3
        in (
            sAll.toDate().allowedDaysInFuture(2) and
    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.


    The other snippet below however would not pass this check.