나는 DateTime
객체로 String
을 분석하기 위해 노력하고있어 문자열을 구문 분석하지만, 그럼 나는 그것이 DateTime
객체로 변환되고 끝나는 그것을 문자열 30/05/1970
을주고 가정 해 봅시다 항상 1로 월을 기본값으로 보인다 달 값은 1
입니다. 메서드에 전달되는 형식이 dd/mm/yyyy
것을DateTime 개체
public static DateTime ToDateTime(this String value, String format)
{
Contract.Requires(!String.IsNullOrEmpty(value));
Contract.Requires(!String.IsNullOrEmpty(format));
DateTime date;
if (DateTime.TryParseExact(value, format, CultureInfo.InvariantCulture, DateTimeStyles.None, out date))
{
return date;
}
throw new ArgumentException("Input value is not a valid date.");
}
참고 :
여기에 코드입니다.
의견이 있으십니까?
의 달입니다'MM'은하지'네 –