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

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");
try {
} catch (ParseException pe) {
return false;
return true;
public static void main(String[] args) {
/* System.out.println(checkDate("30-03-2017")); */




Love podcasts or audiobooks? Learn on the go with our new app.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Code Factory

Code Factory

More from Medium

JAVA: Exception Handling

Introduction to Java: A Beginner’s Guide

Java - Rewriting Traditional Codes With Streams #1 (filter, foreach)

Responsibility Driven Object Oriented Design