1. import java.time.LocalDate;
  2. import java.time.temporal.ChronoUnit;
  3. import java.util.HashMap;
  4. import java.util.Map;
  5. public class ExecutionTracker {
  6. private static final Map<LocalDate, Integer> executionCounts = new HashMap<>();
  7. public static void trackExecution(LocalDate date) {
  8. // Increment the count for the given date.
  9. executionCounts.put(date, executionCounts.getOrDefault(date, 0) + 1);
  10. }
  11. public static int getExecutionCount(LocalDate date) {
  12. // Return the number of executions for the given date.
  13. return executionCounts.getOrDefault(date, 0);
  14. }
  15. public static void main(String[] args) {
  16. // Example usage:
  17. LocalDate today = LocalDate.now();
  18. trackExecution(today);
  19. LocalDate yesterday = today.minusDays(1);
  20. trackExecution(yesterday);
  21. LocalDate tomorrow = today.plusDays(1);
  22. trackExecution(tomorrow);
  23. // Print the execution counts for specific dates.
  24. System.out.println("Execution count for " + today + ": " + getExecutionCount(today));
  25. System.out.println("Execution count for " + yesterday + ": " + getExecutionCount(yesterday));
  26. System.out.println("Execution count for " + tomorrow + ": " + getExecutionCount(tomorrow));
  27. }
  28. }

Add your comment