public static boolean isValidDate( String dateString, String dateFormat ) {
    try {
      getDateFromStringByFormat( dateString, dateFormat );
      return true;
    } catch ( ParseException e ) {
      return false;
    }
  }
@Test
  public void testIsValidDate() {
    assertTrue( DateDetector.isValidDate( SAMPLE_DATE_STRING_US ) );
    assertFalse( DateDetector.isValidDate( null ) );
    assertTrue( DateDetector.isValidDate( SAMPLE_DATE_STRING, SAMPLE_DATE_FORMAT ) );
    assertFalse( DateDetector.isValidDate( SAMPLE_DATE_STRING, null ) );
  }