ApexSensei

Drills Apex basics

Working with dates

Build a Date with Date.newInstance.

Your task

Use Apex date math on two month-end dates and print what changes.

Date yearEnd = null;
Date nextDay = null;
Boolean yearChanged = false;

Date monthEnd = null;
Date nextMonth = null;

Requirements

  1. addMonths(1) should be used
  2. year() should be used
  3. daysBetween should be used
  4. Next day: 2025-01-01 00:00:00 should be printed
  5. Year changed: true should be printed
  6. Next month: 2025-02-28 00:00:00 should be printed
  7. Days apart: 28 should be printed

Sign in to open this drill