Skip to content

Instantly share code, notes, and snippets.

@yujuwon
Created January 23, 2013 02:18
Show Gist options
  • Save yujuwon/4601252 to your computer and use it in GitHub Desktop.
Save yujuwon/4601252 to your computer and use it in GitHub Desktop.
public bool IsDate(String date)
{
bool result = true;
String datePattern = @"^(19[0-9]{2}|2[0-9]{3})-(0[1-9]|1[012])-([123]0|[012][1-9]|31)$";
if(Regex.IsMatch(date, datePattern) == false)
{
result = false;
}
return result;
}
public bool IsTime(String time)
{
bool result = true;
String timePattern = @"^([0-9]{2}):([0-9]{2}):([0-9]{2})$";
if(Regex.IsMatch(time, timePattern) == false)
{
result = false;
}
return result;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment