Using Custom Labels in a Class

You can access these custom labels like this:

if(monitoringFrequency == System.Label.daily){
    return dateValue.addDays(1);
}else if(monitoringFrequency == System.Label.weekly){
    return dateValue.addDays(7);
}else if(monitoringFrequency == System.Label.monthly){
    return dateValue.addMonths(1);
}

Do make sure that the names of the custom labels are correct.

For more information, see: https://help.salesforce.com/HTViewHelpDoc?id=cl_about.htm&language=en_US


We can put label in salesforce these ways:

Visualforce Page: $Label.Label_API_Name

Lightning Component Page {!$Label.c.Label_API_Name}

Apex Class String getLabelName = Label.Label_API_Name;

or directly System.Label.Label_API_Name

hope this helps you.