Well, the easiest approach:
int year = new DateTime().getYear(); DateTime[] dates = new DateTime[] { new DateTime(year, 6, 15, 0, 0), new DateTime(year, 9, 15, 0, 0), };
This is not ideal for variable variables, as it introduces an additional instance variable ( year ) for no good reason, but you can easily include it in a helper method:
private final DateTime[] importantDates = createImportantDatesThisYear(); private static DateTime[] createImportantDatesThisYear() { int year = new DateTime().getYear(); return new DateTime[] { new DateTime(year, 6, 15, 0, 0), new DateTime(year, 9, 15, 0, 0), }; }
Please note that all this code assumes that you want
source share