can we invoke another class method from batch apex? I need to call EndDateStartDateDifference method (from DaysDifference class) in TimeCalculator batch apex with firstDate value (fetch in query) and finish date value(system.today).
simple class:-
public with sharing class DaysDifference {
public static integer EndDateStartDateDifference(date firstDate, date finishDate) {
integer difference= firstDate.daysBetween(finishDate);
return difference;
}
}
Batch apex:-
global class TimeCalculator implements Database.Batchable<SObject>{
global Database.QueryLocator start(Database.BatchableContext context) {
string getTLRecord = 'SELECT Start_Date__c FROM Time_Log__c';
return Database.getQueryLocator(getTLRecord);
}
global void execute (database.batchableContext context, List<Time_Log__c> scope){
DaysDifference.EndDateStartDateDifference(??,??);
}
global void finish(database.batchableContext context){
}
}