The D2 visa's total validity of 1, 2 or 5 years starts on the day it is issued, not on your first entry. After issuance, you have 90 days to enter Indonesia for the first time.
Every day between issuance and your first entry counts toward your total validity. So apply fairly close to your planned trip, but leave enough time for processing (7–10 working days). If you're unsure about the best time to apply, message us and we'll help you plan it.