🔸 THE CHALLENGE (TRY BEFORE YOU SCROLL)
You have an EJB timer method annotated like this:
@Schedule(minute="*/20", hour="1-2", dayOfMonth="-10")
Question: When does this timer actually fire? 🤔
▪️ A) Every 20 minutes, during 01:00–02:59, on the 10th day from the end of the month
▪️ B) Every 10 days, at 01:20 and 02:20
▪️ C) Every 20 minutes, during 01:00–02:59 in the morning and again in the evening, on the 10th day of each month
▪️ D) 10 days from the end of the month, at 01:20 and 02:20

🔸 ANSWER
✅ A) Every 20 minutes, between 01:00 and 02:59, on the 10th day from the end of the month.
Breakdown:
▪️ minute="*/20" → minutes 0, 20, 40 (every hour)
▪️ hour="1-2" → hours 1 and 2 (24h clock → early morning, not evening)
▪️ dayOfMonth="-10" → the day that is 10 days before the last day of the month
So on that specific day, it fires at:
▪️ 01:00, 01:20, 01:40
▪️ 02:00, 02:20, 02:40 ✅
🔸 TL;DR
It runs every 20 minutes during 01:00–02:59, but only on the 10th day from the end of each month.
🔸 TAKEAWAYS
▪️ */N means “every N units starting at 0” (for minutes/hours/seconds).
▪️ 1-2 means hours 1 and 2, using 0–23 (no PM unless you explicitly write it, e.g., 13-14).
▪️ Negative dayOfMonth values count backward from month end.
▪️ When in doubt, expand it into real timestamps—humans debug schedules better than patterns. 😄
#Java #JakartaEE #EnterpriseJava #EJB #TimerService #Backend #Scheduling #JavaDevelopers #Certification #SoftwareEngineering