I would like to know how I can calculate in java how many days a month has and how many days a year has according to the date entered by a user. So far in the program it shows me the day of the month, day of the week, day of the year, name of the month, number of the month and the year. But I don't know what to use to get how many days there are in a given month and year. I insert the code here below, (Thanks to all).
private static Scanner sc;
public static void main(String[] args) {
sc = new Scanner (System.in);
System.out.print("Introduzca una fecha (yyyy-MM-dd): ");
String fecha = sc.nextLine();
LocalDate fecha1 = LocalDate.parse(fecha);
DateTimeFormatter personalizado = DateTimeFormatter.ofPattern("yyyy-MM-dd");
LocalDate fecha1personalizado = LocalDate.parse(fecha,personalizado);
int diaMes = fecha1.getDayOfMonth();
DayOfWeek diaSemana = fecha1.getDayOfWeek();
int diaAnyo = fecha1.getDayOfYear();
Month nombreMes = fecha1.getMonth();
int numeroMes = fecha1.getMonthValue();
System.out.printf("La fecha introducida es: %s\n ", fecha1personalizado);
int anyo = fecha1.getYear();
System.out.println("Información sobre la fecha introducida");
String caracter ="*";
int count = 39;
System.out.println(caracter.repeat(count));
System.out.printf("Día del mes: %d\n", diaMes);
System.out.printf("Día de la semana: %s\n", diaSemana);
System.out.printf("Día del año: %d\n", diaAnyo);
System.out.printf("Nombre del mes: %s\n", nombreMes);
System.out.printf("Número de mes: %d\n", numeroMes);
System.out.printf("Año: %d\n", anyo);
System.out.printf("Este mes tiene %s días"); // diaspormes
System.out.printf("Este año tiene %s días"); // diasporaño