+ Start a Discussion
David_David_ 

Data class method: Quick question regarding isLeapYear

Hey there,

I have a quick question regarding the usage of isLeapYear for a Date. 

Does isLeapYear always require a parameter within the brackets? This code apparently works...
Date myDate = Date.newInstance(2041, 11, 19);
Boolean dateIsLeapYear = Date.isLeapYear(myDate.year());
System.debug(dateIsLeapYear);
... but what about next one? I guess it's not possible to place first the variable and leave the brackets empty:
Date myDate = Date.newInstance(2041, 11, 19);
Boolean dateIsLeapYear = myDate.isLeapYear();
System.debug(dateIsLeapYear);
Just wanna make sure.

Thanks for your help!
Best Answer chosen by David_
ApuroopApuroop
Yes it always requires an Argument. The second snippet would error out saying that Method does not exist or incorrect signature: void isLeapYear() from the type Date

Refer to this for the Date class:
https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_methods_system_date.htm