Created
November 25, 2014 15:15
-
-
Save prakash-patel/b11b8547c99afd8f87df to your computer and use it in GitHub Desktop.
Validate the date time
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// <summary> | |
/// Validates the date time. yyyymmddhhmmssfffk | |
/// </summary> | |
/// <param name="dateString">The date string.</param> | |
public bool ValidateDateTime(string dateString) | |
{ | |
const string malformedTimeZone = | |
@"^\d{4}(?:(?:0[0-9]|1[0-2])(?:(?:[0-2][0-9]|3[0-1]))?(?:(?:[0-1][0-9]|2[0-4]))?(?:(?:[0-5][0-9]))?(?:(?:[0-5][0-9])(?:\.\d+)?)?)?(?:[+-](0[0-9]|1[0-2]):[0-5][0-9])?$"; | |
return Regex.IsMatch(dateString, malformedTimeZone); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment