DateTimeFormatInfo 클래스
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
날짜 및 시간 값 형식에 대한 문화권별 정보를 제공합니다.
public ref class DateTimeFormatInfo sealed : IFormatProvider
public ref class DateTimeFormatInfo sealed : ICloneable, IFormatProvider
public ref class DateTimeFormatInfo sealed : ICloneable, IFormatProvider, System::Runtime::Serialization::ISerializable
public sealed class DateTimeFormatInfo : IFormatProvider
public sealed class DateTimeFormatInfo : ICloneable, IFormatProvider
[System.Serializable]
public sealed class DateTimeFormatInfo : ICloneable, IFormatProvider, System.Runtime.Serialization.ISerializable
[System.Serializable]
[System.Runtime.InteropServices.ComVisible(true)]
public sealed class DateTimeFormatInfo : ICloneable, IFormatProvider
type DateTimeFormatInfo = class
interface IFormatProvider
type DateTimeFormatInfo = class
interface ICloneable
interface IFormatProvider
[<System.Serializable>]
type DateTimeFormatInfo = class
interface ICloneable
interface IFormatProvider
interface ISerializable
[<System.Serializable>]
[<System.Runtime.InteropServices.ComVisible(true)>]
type DateTimeFormatInfo = class
interface ICloneable
interface IFormatProvider
Public NotInheritable Class DateTimeFormatInfo
Implements IFormatProvider
Public NotInheritable Class DateTimeFormatInfo
Implements ICloneable, IFormatProvider
Public NotInheritable Class DateTimeFormatInfo
Implements ICloneable, IFormatProvider, ISerializable
- 상속
-
DateTimeFormatInfo
- 특성
- 구현
예제
다음 예제에서는 리플렉션을 사용하여 영어(미국) 문화권에 대한 개체의 DateTimeFormatInfo 속성을 가져옵니다. 사용자 지정 서식 문자열을 포함하고 해당 문자열을 사용하여 서식이 지정된 날짜를 표시하는 속성의 값을 표시합니다.
using System;
using System.Globalization;
using System.Reflection;
public class Example
{
public static void Main()
{
// Get the properties of an en-US DateTimeFormatInfo object.
DateTimeFormatInfo dtfi = CultureInfo.GetCultureInfo("en-US").DateTimeFormat;
Type typ = dtfi.GetType();
PropertyInfo[] props = typ.GetProperties();
DateTime value = new DateTime(2012, 5, 28, 11, 35, 0);
foreach (var prop in props) {
// Is this a format pattern-related property?
if (prop.Name.Contains("Pattern")) {
string fmt = prop.GetValue(dtfi, null).ToString();
Console.WriteLine("{0,-33} {1} \n{2,-37}Example: {3}\n",
prop.Name + ":", fmt, "",
value.ToString(fmt));
}
}
}
}
// The example displays the following output:
// FullDateTimePattern: dddd, MMMM dd, yyyy h:mm:ss tt
// Example: Monday, May 28, 2012 11:35:00 AM
//
// LongDatePattern: dddd, MMMM dd, yyyy
// Example: Monday, May 28, 2012
//
// LongTimePattern: h:mm:ss tt
// Example: 11:35:00 AM
//
// MonthDayPattern: MMMM dd
// Example: May 28
//
// RFC1123Pattern: ddd, dd MMM yyyy HH':'mm':'ss 'GMT'
// Example: Mon, 28 May 2012 11:35:00 GMT
//
// ShortDatePattern: M/d/yyyy
// Example: 5/28/2012
//
// ShortTimePattern: h:mm tt
// Example: 11:35 AM
//
// SortableDateTimePattern: yyyy'-'MM'-'dd'T'HH':'mm':'ss
// Example: 2012-05-28T11:35:00
//
// UniversalSortableDateTimePattern: yyyy'-'MM'-'dd HH':'mm':'ss'Z'
// Example: 2012-05-28 11:35:00Z
//
// YearMonthPattern: MMMM, yyyy
// Example: May, 2012
Imports System.Globalization
Imports System.Reflection
Module Example
Public Sub Main()
' Get the properties of an en-US DateTimeFormatInfo object.
Dim dtfi As DateTimeFormatInfo = CultureInfo.GetCultureInfo("en-US").DateTimeFormat
Dim typ As Type = dtfi.GetType()
Dim props() As PropertyInfo = typ.GetProperties()
Dim value As Date = #05/28/2012 11:35AM#
For Each prop In props
' Is this a format pattern-related property?
If prop.Name.Contains("Pattern") Then
Dim fmt As String = CStr(prop.GetValue(dtfi, Nothing))
Console.WriteLine("{0,-33} {1} {2}{3,-37}Example: {4}",
prop.Name + ":", fmt, vbCrLf, "",
value.ToString(fmt))
Console.WriteLine()
End If
Next
End Sub
End Module
' The example displays the following output:
' FullDateTimePattern: dddd, MMMM dd, yyyy h:mm:ss tt
' Example: Monday, May 28, 2012 11:35:00 AM
'
' LongDatePattern: dddd, MMMM dd, yyyy
' Example: Monday, May 28, 2012
'
' LongTimePattern: h:mm:ss tt
' Example: 11:35:00 AM
'
' MonthDayPattern: MMMM dd
' Example: May 28
'
' RFC1123Pattern: ddd, dd MMM yyyy HH':'mm':'ss 'GMT'
' Example: Mon, 28 May 2012 11:35:00 GMT
'
' ShortDatePattern: M/d/yyyy
' Example: 5/28/2012
'
' ShortTimePattern: h:mm tt
' Example: 11:35 AM
'
' SortableDateTimePattern: yyyy'-'MM'-'dd'T'HH':'mm':'ss
' Example: 2012-05-28T11:35:00
'
' UniversalSortableDateTimePattern: yyyy'-'MM'-'dd HH':'mm':'ss'Z'
' Example: 2012-05-28 11:35:00Z
'
' YearMonthPattern: MMMM, yyyy
' Example: May, 2012
설명
이 API에 대한 자세한 내용은 DateTimeFormatInfo에 대한 추가 API 설명을 참조하세요.
생성자
DateTimeFormatInfo() |
문화권 독립(고정)적인 DateTimeFormatInfo 클래스의 쓰기 가능한 새 인스턴스를 초기화합니다. |
속성
AbbreviatedDayNames |
문화권별 약식 요일 이름이 들어 있는 String 형식의 1차원 배열을 가져오거나 설정합니다. |
AbbreviatedMonthGenitiveNames |
현재 DateTimeFormatInfo 개체와 연결된 약식 월 이름의 문자열 배열을 가져오거나 설정합니다. |
AbbreviatedMonthNames |
문화권별 약식 월 이름이 들어 있는 1차원 문자열 배열을 가져오거나 설정합니다. |
AMDesignator |
"AM(ante meridiem)"(오전) 시간에 대한 문자열 지정자를 가져오거나 설정합니다. |
Calendar |
현재 문화권에 사용할 달력을 가져오거나 설정합니다. |
CalendarWeekRule |
연도의 첫째 주를 결정하는 데 사용되는 규칙을 지정하는 값을 가져오거나 설정합니다. |
CurrentInfo |
현재 문화권에 따라 값의 형식을 지정하는 읽기 전용 DateTimeFormatInfo 개체를 가져옵니다. |
DateSeparator |
날짜의 구성 요소 즉, 연도, 월, 일을 구분하는 문자열을 가져오거나 설정합니다. |
DayNames |
문화권별 전체 요일 이름이 들어 있는 1차원 문자열 배열을 가져오거나 설정합니다. |
FirstDayOfWeek |
주의 첫째 요일을 가져오거나 설정합니다. |
FullDateTimePattern |
긴 날짜 및 긴 시간 값에 대한 사용자 지정 서식 문자열을 가져오거나 설정합니다. |
InvariantInfo |
문화권 독립(고정)적인 기본 읽기 전용 DateTimeFormatInfo 개체를 가져옵니다. |
IsReadOnly |
DateTimeFormatInfo 개체가 읽기 전용인지 여부를 나타내는 값을 가져옵니다. |
LongDatePattern |
긴 날짜 값의 사용자 지정 형식 문자열을 가져오거나 설정합니다. |
LongTimePattern |
긴 시간 값의 사용자 지정 형식 문자열을 가져오거나 설정합니다. |
MonthDayPattern |
월 및 일 값에 대한 사용자 지정 서식 문자열을 가져오거나 설정합니다. |
MonthGenitiveNames |
현재 DateTimeFormatInfo 개체와 연결된 월 이름의 문자열 배열을 가져오거나 설정합니다. |
MonthNames |
문화권별 전체 월 이름이 들어 있는 String 형식의 1차원 배열을 가져오거나 설정합니다. |
NativeCalendarName |
현재 DateTimeFormatInfo 개체와 연결된 달력의 네이티브 이름을 가져옵니다. |
PMDesignator |
"PM(post meridiem)"(오후) 시간에 대한 문자열 지정자를 가져오거나 설정합니다. |
RFC1123Pattern |
IETF(Internet Engineering Task Force) RFC(Request for Comments) 1123 사양을 기반으로 하는 시간 값에 대한 사용자 지정 서식 문자열을 가져옵니다. |
ShortDatePattern |
짧은 날짜 값의 사용자 지정 형식 문자열을 가져오거나 설정합니다. |
ShortestDayNames |
현재 DateTimeFormatInfo 개체와 연결된 가장 짧은 고유 약식 요일 이름의 문자열 배열을 가져오거나 설정합니다. |
ShortTimePattern |
짧은 시간 값의 사용자 지정 형식 문자열을 가져오거나 설정합니다. |
SortableDateTimePattern |
정렬 가능한 날짜 및 시간 값에 대한 사용자 지정 서식 문자열을 가져옵니다. |
TimeSeparator |
시간의 구성 요소 즉, 시, 분, 초를 구분하는 문자열을 가져오거나 설정합니다. |
UniversalSortableDateTimePattern |
ISO 8601에서 정의된 정렬 가능한 유니버설 날짜 및 시간 문자열에 대한 사용자 지정 서식 문자열을 가져옵니다. |
YearMonthPattern |
연도 및 월 값에 대한 사용자 지정 서식 문자열을 가져오거나 설정합니다. |
메서드
Clone() |
DateTimeFormatInfo의 부분 복사본을 만듭니다. |
Equals(Object) |
지정된 개체가 현재 개체와 같은지 확인합니다. (다음에서 상속됨 Object) |
GetAbbreviatedDayName(DayOfWeek) |
현재 DateTimeFormatInfo 개체와 연결된 문화권에 기반하여 지정된 요일의 문화권별 약식 이름을 반환합니다. |
GetAbbreviatedEraName(Int32) |
약식 형태가 있는 경우 지정된 연대의 약식 이름이 들어 있는 문자열을 반환합니다. |
GetAbbreviatedMonthName(Int32) |
현재 DateTimeFormatInfo 개체와 연결된 문화권에 기반하여 지정된 월의 문화권별 약식 이름을 반환합니다. |
GetAllDateTimePatterns() |
날짜 및 시간 값의 형식을 지정할 수 있는 모든 표준 패턴을 반환합니다. |
GetAllDateTimePatterns(Char) |
지정된 표준 형식 문자열을 사용하여 날짜 및 시간 값의 형식을 지정할 수 있는 모든 패턴을 반환합니다. |
GetDayName(DayOfWeek) |
현재 DateTimeFormatInfo 개체와 연결된 문화권에 기반하여 지정된 요일의 문화권별 전체 이름을 반환합니다. |
GetEra(String) |
지정된 서기를 나타내는 정수를 반환합니다. |
GetEraName(Int32) |
지정된 연대 이름이 들어 있는 문자열을 반환합니다. |
GetFormat(Type) |
날짜 및 시간 서식 서비스를 제공하는 지정된 형식의 개체를 반환합니다. |
GetHashCode() |
기본 해시 함수로 작동합니다. (다음에서 상속됨 Object) |
GetInstance(IFormatProvider) |
지정된 DateTimeFormatInfo 개체와 연결된 IFormatProvider 개체를 반환합니다. |
GetMonthName(Int32) |
현재 DateTimeFormatInfo 개체와 연결된 문화권에 기반하여 지정된 월의 문화권별 전체 이름을 반환합니다. |
GetShortestDayName(DayOfWeek) |
현재 DateTimeFormatInfo 개체와 연결된 지정된 요일의 가장 짧은 약식 요일 이름을 가져옵니다. |
GetType() |
현재 인스턴스의 Type을 가져옵니다. (다음에서 상속됨 Object) |
MemberwiseClone() |
현재 Object의 단순 복사본을 만듭니다. (다음에서 상속됨 Object) |
ReadOnly(DateTimeFormatInfo) |
읽기 전용 DateTimeFormatInfo 래퍼를 반환합니다. |
SetAllDateTimePatterns(String[], Char) |
지정된 표준 형식 문자열에 해당하는 사용자 지정 날짜 및 시간 형식 문자열을 설정합니다. |
ToString() |
현재 개체를 나타내는 문자열을 반환합니다. (다음에서 상속됨 Object) |
명시적 인터페이스 구현
ISerializable.GetObjectData(SerializationInfo, StreamingContext) |
대상 개체를 직렬화하는 데 필요한 데이터를 SerializationInfo에 채웁니다. |
적용 대상
추가 정보
.NET
피드백
https://aka.ms/ContentUserFeedback
출시 예정: 2024년 내내 콘텐츠에 대한 피드백 메커니즘으로 GitHub 문제를 단계적으로 폐지하고 이를 새로운 피드백 시스템으로 바꿀 예정입니다. 자세한 내용은 다음을 참조하세요.다음에 대한 사용자 의견 제출 및 보기