/** * @author lautturi.com * Java example: See how many days there are in February,2002 */ import java.util.*; import java.time.YearMonth; public class Lautturi { public static void main(String[] args){ int daysInMonth = YearMonth.of(2002, 2).lengthOfMonth(); System.out.println("There are " + daysInMonth+" days in 2002,2"); } }
output:
There are 28 days in 2002,2