Check String value is a valid date or not | Code Factory

Donate : Link

Reference Link : Link

Applications : Link

package com.codeFactory;import java.text.ParseException;
import java.text.SimpleDateFormat;
public class Main {
public static boolean checkDate(String inDate) {
/* SimpleDateFormat dateFormat = new SimpleDateFormat("dd-MM-yyyy"); */
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
dateFormat.setLenient(false);
try {
dateFormat.parse(inDate.trim());
} catch (ParseException pe) {
return false;
}
return true;
}
public static void main(String[] args) {
/* System.out.println(checkDate("30-03-2017")); */
System.out.println(checkDate("2017-02-28"));
}
}