import java.time.LocalDate;
import java.time.temporal.ChronoUnit;
import java.util.HashMap;
import java.util.Map;
public class ExecutionTracker {
private static final Map<LocalDate, Integer> executionCounts = new HashMap<>();
public static void trackExecution(LocalDate date) {
// Increment the count for the given date.
executionCounts.put(date, executionCounts.getOrDefault(date, 0) + 1);
}
public static int getExecutionCount(LocalDate date) {
// Return the number of executions for the given date.
return executionCounts.getOrDefault(date, 0);
}
public static void main(String[] args) {
// Example usage:
LocalDate today = LocalDate.now();
trackExecution(today);
LocalDate yesterday = today.minusDays(1);
trackExecution(yesterday);
LocalDate tomorrow = today.plusDays(1);
trackExecution(tomorrow);
// Print the execution counts for specific dates.
System.out.println("Execution count for " + today + ": " + getExecutionCount(today));
System.out.println("Execution count for " + yesterday + ": " + getExecutionCount(yesterday));
System.out.println("Execution count for " + tomorrow + ": " + getExecutionCount(tomorrow));
}
}
Add your comment