Here you can find the source of isValidDate(DateFormat sdf, String date)
public static boolean isValidDate(DateFormat sdf, String date)
//package com.java2s; /******************************************************************************* * Copyright (c) 2010 Robert "Unlogic" Olofsson (unlogic@unlogic.se). * All rights reserved. This program and the accompanying materials * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0-standalone.html ******************************************************************************/ import java.text.DateFormat; import java.text.ParseException; public class Main { public static boolean isValidDate(DateFormat sdf, String date) { try {//from w ww.ja v a 2s . c o m sdf.parse(date); } catch (ParseException e) { return false; } catch (RuntimeException e) { return false; } return true; } }