Get Month Last Date In Apex

Sample Code:

Date dt = System.today();
Integer numberOfDays = Date.daysInMonth(dt.year(), dt.month());
Date lastDayOfMonth = Date.newInstance(dt.year(), dt.month(), numberOfDays);
System.debug('lastDayOfMonth-' + lastDayOfMonth);