Can't access @Field global variable

Viewed 32

I have these global variable inside my Groovy script

@Field ZonedDateTime currentDateTime = ZonedDateTime.now(ZoneId.of("UTC"))

@Field DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSSZ")

But I can't seem to access it inside the class in my script :(

class SmsMessageDeliveryPartResult {
    String dateSent
    String dateDeliveryReceiptReceived

    DeliveryResult() {
        this.dateSent = currentDateTime.format(formatter)
        this.dateDeliveryReceiptReceived = currentDateTime.format(formatter)
    }
}

I get this error:

Caught: groovy.lang.MissingPropertyException: No such property: currentDateTime for class:
0 Answers
Related