|
이 문서는 기계로 번역한 것입니다. 원본 텍스트를 보려면 포인터를 문서의 문장 위로 올리십시오. 추가 정보
|
번역
원본
|
DateTimeOffset.ParseExact 메서드 (String, String, IFormatProvider)
네임스페이스: System
어셈블리: mscorlib(mscorlib.dll)
public static DateTimeOffset ParseExact( string input, string format, IFormatProvider formatProvider )
매개 변수
- input
- 형식: System.String
변환할 날짜 및 시간이 포함된 문자열입니다.
- format
- 형식: System.String
input의 예상 형식을 정의하는 형식 지정자입니다.
- formatProvider
- 형식: System.IFormatProvider
input에 대한 문화권별 서식 지정 정보를 제공하는 개체입니다.
| 예외 | 조건 |
|---|---|
| ArgumentException | |
| ArgumentNullException | |
| FormatException |
input을 해석하는 기반이 되는 문화권을 나타내는 CultureInfo 개체. 해당 DateTimeFormat 속성을 통해 반환되는 DateTimeFormatInfo 개체는 input의 기호와 형식을 정의합니다. 날짜 및 시간 데이터의 형식을 정의하는 DateTimeFormatInfo 개체
string dateString, format; DateTimeOffset result; CultureInfo provider = CultureInfo.InvariantCulture; // Parse date-only value with invariant culture. dateString = "06/15/2008"; format = "d"; try { result = DateTimeOffset.ParseExact(dateString, format, provider); Console.WriteLine("{0} converts to {1}.", dateString, result.ToString()); } catch (FormatException) { Console.WriteLine("{0} is not in the correct format.", dateString); } // Parse date-only value without leading zero in month using "d" format. // Should throw a FormatException because standard short date pattern of // invariant culture requires two-digit month. dateString = "6/15/2008"; try { result = DateTimeOffset.ParseExact(dateString, format, provider); Console.WriteLine("{0} converts to {1}.", dateString, result.ToString()); } catch (FormatException) { Console.WriteLine("{0} is not in the correct format.", dateString); } // Parse date and time with custom specifier. dateString = "Sun 15 Jun 2008 8:30 AM -06:00"; format = "ddd dd MMM yyyy h:mm tt zzz"; try { result = DateTimeOffset.ParseExact(dateString, format, provider); Console.WriteLine("{0} converts to {1}.", dateString, result.ToString()); } catch (FormatException) { Console.WriteLine("{0} is not in the correct format.", dateString); } // Parse date and time with offset without offset//s minutes. // Should throw a FormatException because "zzz" specifier requires leading // zero in hours. dateString = "Sun 15 Jun 2008 8:30 AM -06"; try { result = DateTimeOffset.ParseExact(dateString, format, provider); Console.WriteLine("{0} converts to {1}.", dateString, result.ToString()); } catch (FormatException) { Console.WriteLine("{0} is not in the correct format.", dateString); } // The example displays the following output: // 06/15/2008 converts to 6/15/2008 12:00:00 AM -07:00. // 6/15/2008 is not in the correct format. // Sun 15 Jun 2008 8:30 AM -06:00 converts to 6/15/2008 8:30:00 AM -06:00. // Sun 15 Jun 2008 8:30 AM -06 is not in the correct format.
Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008(서버 코어 역할은 지원되지 않음), Windows Server 2008 R2(서버 코어 역할은 SP1 이상에서 지원, Itanium은 지원되지 않음)
.NET Framework에서 모든 플랫폼의 전체 버전을 지원하지는 않습니다. 지원되는 버전의 목록을 보려면 .NET Framework 시스템 요구 사항을 참조하십시오.