Here you can find the source of validateDate(String input, DateTimeFormatter formatter)
public static LocalDate validateDate(String input, DateTimeFormatter formatter)
//package com.java2s; //License from project: Open Source License import java.time.DayOfWeek; import java.time.LocalDate; import java.time.format.DateTimeFormatter; public class Main { public static boolean validateDate(LocalDate date) { return !(date.getDayOfWeek().equals(DayOfWeek.SATURDAY) || date.getDayOfWeek().equals(DayOfWeek.SUNDAY)); }//from w w w.j av a2 s.c o m public static LocalDate validateDate(String input) { return validateDate(input, DateTimeFormatter.ISO_LOCAL_DATE); } public static LocalDate validateDate(String input, DateTimeFormatter formatter) { if (!input.isEmpty()) { try { LocalDate date = LocalDate.parse(input, formatter); if (validateDate(date)) { return date; } } catch (Exception e) { return null; } } return null; } }