다음을 통해 공유


CultureInfo.DateTimeFormat 속성

날짜와 시간 표시를 위한 culture 형식을 정의하는 DateTimeFormatInfo를 가져오거나 설정합니다.

네임스페이스: System.Globalization
어셈블리: mscorlib(mscorlib.dll)

구문

‘선언
Public Overridable Property DateTimeFormat As DateTimeFormatInfo
‘사용 방법
Dim instance As CultureInfo
Dim value As DateTimeFormatInfo

value = instance.DateTimeFormat

instance.DateTimeFormat = value
public virtual DateTimeFormatInfo DateTimeFormat { get; set; }
public:
virtual property DateTimeFormatInfo^ DateTimeFormat {
    DateTimeFormatInfo^ get ();
    void set (DateTimeFormatInfo^ value);
}
/** @property */
public DateTimeFormatInfo get_DateTimeFormat ()

/** @property */
public void set_DateTimeFormat (DateTimeFormatInfo value)
public function get DateTimeFormat () : DateTimeFormatInfo

public function set DateTimeFormat (value : DateTimeFormatInfo)

속성 값

날짜와 시간 표시를 위한 culture 형식을 정의하는 DateTimeFormatInfo입니다.

예외

예외 형식 조건

ArgumentNullException

속성이 Null 참조(Visual Basic의 경우 Nothing)로 설정된 경우

NotSupportedException

CultureInfo가 중립적 culture에 대한 것일 경우

InvalidOperationException

DateTimeFormat 속성 또는 DateTimeFormatInfo 속성 중 하나가 설정되고 CultureInfo가 읽기 전용인 경우

설명

DateTimeFormatInfo는 고정 culture나 특정 culture에 대해서만 만들 수 있고, 중립 culture에 대해서는 만들 수 없습니다.

일반적으로 culture는 고정 culture, 중립 culture 및 특정 culture로 나누어집니다.

고정 culture는 culture를 구분하지 않으므로, 빈 문자열("")을 사용하여 고정 culture를 이름별로 지정하거나 culture 식별자 0x007F별로 지정할 수 있습니다. InvariantCulture는 고정 culture의 인스턴스를 가져옵니다. 이 인스턴스는 영어만 표시하고 국가/지역은 표시하지 않는 인스턴스로, culture를 필요로 하는 Globalization 네임스페이스의 거의 모든 메서드에 사용될 수 있습니다.

중립 culture는 언어만 표시하고 국가/지역은 표시하지 않는 culture이고, 특정 culture는 언어와 국가/지역을 모두 표시하는 culture입니다. 예를 들어, "fr"는 중립 culture이고 "fr-FR"는 특정 culture입니다. "zh-CHS"(중국어 간체)와 "zh-CHT"(중국어 번체)는 모두 중립 culture입니다.

재정의

사용자는 제어판의 국가별 설정 옵션을 사용하여 Windows의 현재 culture와 관련된 일부 값을 재정의할 수 있습니다. 예를 들어, 날짜를 다른 형식으로 표시하거나 해당 culture의 기본 통화 단위가 아닌 다른 통화 단위를 사용할 수 있습니다.

UseUserOverridetrue이고 지정된 culture가 Windows의 현재 culture와 일치하면 CultureInfoDateTimeFormat 속성에서 반환하는 DateTimeFormatInfo 인스턴스의 속성 및 NumberFormat 속성에서 반환하는 NumberFormatInfo 인스턴스의 속성에 대한 사용자 설정을 포함하는 재정의를 사용합니다. 사용자 설정이 CultureInfo에 연결된 culture와 호환되지 않는 경우(예: 선택한 달력이 OptionalCalendars 중 하나가 아닌 경우) 해당 메서드의 결과와 속성 값은 정의되지 않습니다.

DateTimeFormat 속성과 NumberFormat 속성의 값은 해당 속성에 액세스할 때까지 계산되지 않습니다. 응용 프로그램이 실행되는 동안 제어판을 사용하여 현재 culture를 새 culture로 변경한 다음 DateTimeFormat 또는 NumberFormat 속성에 액세스할 경우, 응용 프로그램은 원래 culture의 재정의 대신 새 culture의 기본값을 가져옵니다. 원래의 현재 culture에 대한 재정의를 보존하려는 경우 현재 culture를 변경하기 전에 DateTimeFormatNumberFormat 속성에 액세스합니다.

호출자 참고 사항 DateTimeFormatInfo.CalendarTaiwanCalendar이고 Thread.CurrentCulture는 "zh-TW"가 아니면 DateTimeFormatInfo.NativeCalendarName, DateTimeFormatInfo.GetEraNameDateTimeFormatInfo.GetAbbreviatedEraName은 빈 문자열("")을 반환합니다.

예제

다음 코드 예제에서는 CultureInfo.Clone으로도 CultureInfo와 연관된 DateTimeFormatInfoNumberFormatInfo 인스턴스를 복제할 수 있음을 보여 줍니다.

Imports System
Imports System.Globalization


Public Class SamplesCultureInfo
   
   Public Shared Sub Main()
      
      ' Creates and initializes a CultureInfo.
      Dim myCI As New CultureInfo("en-US", False)
      
      ' Clones myCI and modifies the DTFI and NFI instances associated with the clone.
      Dim myCIclone As CultureInfo = CType(myCI.Clone(), CultureInfo)
      myCIclone.DateTimeFormat.AMDesignator = "a.m."
      myCIclone.DateTimeFormat.DateSeparator = "-"
      myCIclone.NumberFormat.CurrencySymbol = "USD"
      myCIclone.NumberFormat.NumberDecimalDigits = 4
      
      ' Displays the properties of the DTFI and NFI instances associated with the original and with the clone. 
      Console.WriteLine("DTFI/NFI PROPERTY" + ControlChars.Tab + "ORIGINAL" + ControlChars.Tab + "MODIFIED CLONE")
      Console.WriteLine("DTFI.AMDesignator" + ControlChars.Tab + "{0}" + ControlChars.Tab + ControlChars.Tab + "{1}", myCI.DateTimeFormat.AMDesignator, myCIclone.DateTimeFormat.AMDesignator)
      Console.WriteLine("DTFI.DateSeparator" + ControlChars.Tab + "{0}" + ControlChars.Tab + ControlChars.Tab + "{1}", myCI.DateTimeFormat.DateSeparator, myCIclone.DateTimeFormat.DateSeparator)
      Console.WriteLine("NFI.CurrencySymbol" + ControlChars.Tab + "{0}" + ControlChars.Tab + ControlChars.Tab + "{1}", myCI.NumberFormat.CurrencySymbol, myCIclone.NumberFormat.CurrencySymbol)
      Console.WriteLine("NFI.NumberDecimalDigits" + ControlChars.Tab + "{0}" + ControlChars.Tab + ControlChars.Tab + "{1}", myCI.NumberFormat.NumberDecimalDigits, myCIclone.NumberFormat.NumberDecimalDigits)

   End Sub 'Main 

End Class 'SamplesCultureInfo


' This code produces the following output.
'
' DTFI/NFI PROPERTY       ORIGINAL        MODIFIED CLONE
' DTFI.AMDesignator       AM              a.m.
' DTFI.DateSeparator      /               -
' NFI.CurrencySymbol      $               USD
' NFI.NumberDecimalDigits 2               4
using System;
using System.Globalization;


public class SamplesCultureInfo  {

   public static void Main()  {

      // Creates and initializes a CultureInfo.
      CultureInfo myCI = new CultureInfo("en-US", false);

      // Clones myCI and modifies the DTFI and NFI instances associated with the clone.
      CultureInfo myCIclone = (CultureInfo) myCI.Clone();
      myCIclone.DateTimeFormat.AMDesignator = "a.m.";
      myCIclone.DateTimeFormat.DateSeparator = "-";
      myCIclone.NumberFormat.CurrencySymbol = "USD";
      myCIclone.NumberFormat.NumberDecimalDigits = 4;

      // Displays the properties of the DTFI and NFI instances associated with the original and with the clone. 
      Console.WriteLine( "DTFI/NFI PROPERTY\tORIGINAL\tMODIFIED CLONE" );
      Console.WriteLine( "DTFI.AMDesignator\t{0}\t\t{1}", myCI.DateTimeFormat.AMDesignator, myCIclone.DateTimeFormat.AMDesignator );
      Console.WriteLine( "DTFI.DateSeparator\t{0}\t\t{1}", myCI.DateTimeFormat.DateSeparator, myCIclone.DateTimeFormat.DateSeparator );
      Console.WriteLine( "NFI.CurrencySymbol\t{0}\t\t{1}", myCI.NumberFormat.CurrencySymbol, myCIclone.NumberFormat.CurrencySymbol );
      Console.WriteLine( "NFI.NumberDecimalDigits\t{0}\t\t{1}", myCI.NumberFormat.NumberDecimalDigits, myCIclone.NumberFormat.NumberDecimalDigits );
      
   }

}

/*
This code produces the following output.

DTFI/NFI PROPERTY       ORIGINAL        MODIFIED CLONE
DTFI.AMDesignator       AM              a.m.
DTFI.DateSeparator      /               -
NFI.CurrencySymbol      $               USD
NFI.NumberDecimalDigits 2               4

*/
using namespace System;
using namespace System::Globalization;
int main()
{
   
   // Creates and initializes a CultureInfo.
   CultureInfo^ myCI = gcnew CultureInfo( "en-US",false );
   
   // Clones myCI and modifies the DTFI and NFI instances associated with the clone.
   CultureInfo^ myCIclone = dynamic_cast<CultureInfo^>(myCI->Clone());
   myCIclone->DateTimeFormat->AMDesignator = "a.m.";
   myCIclone->DateTimeFormat->DateSeparator = "-";
   myCIclone->NumberFormat->CurrencySymbol = "USD";
   myCIclone->NumberFormat->NumberDecimalDigits = 4;
   
   // Displays the properties of the DTFI and NFI instances associated with the original and with the clone. 
   Console::WriteLine( "DTFI/NFI PROPERTY\tORIGINAL\tMODIFIED CLONE" );
   Console::WriteLine( "DTFI.AMDesignator\t{0}\t\t{1}", myCI->DateTimeFormat->AMDesignator, myCIclone->DateTimeFormat->AMDesignator );
   Console::WriteLine( "DTFI.DateSeparator\t{0}\t\t{1}", myCI->DateTimeFormat->DateSeparator, myCIclone->DateTimeFormat->DateSeparator );
   Console::WriteLine( "NFI.CurrencySymbol\t{0}\t\t{1}", myCI->NumberFormat->CurrencySymbol, myCIclone->NumberFormat->CurrencySymbol );
   Console::WriteLine( "NFI.NumberDecimalDigits\t{0}\t\t{1}", myCI->NumberFormat->NumberDecimalDigits, myCIclone->NumberFormat->NumberDecimalDigits );
}

/*
This code produces the following output.

DTFI/NFI PROPERTY       ORIGINAL        MODIFIED CLONE
DTFI.AMDesignator       AM              a.m.
DTFI.DateSeparator      /               -
NFI.CurrencySymbol      $               USD
NFI.NumberDecimalDigits 2               4
*/
import System.* ;
import System.Globalization.* ;

public class SamplesCultureInfo
{
    public static void main(String[] args)
    {
        // Creates and initializes a CultureInfo.
        CultureInfo myCI =  new CultureInfo("en-US", false);

        // Clones myCI and modifies the DTFI and NFI instances 
        // associated with the clone.
        CultureInfo myCIclone = ((CultureInfo)(myCI.Clone()));
        myCIclone.get_DateTimeFormat().set_AMDesignator( "a.m.");
        myCIclone.get_DateTimeFormat().set_DateSeparator ("-");
        myCIclone.get_NumberFormat().set_CurrencySymbol("USD");
        myCIclone.get_NumberFormat().set_NumberDecimalDigits(4);

        // Displays the properties of the DTFI and NFI instances associated 
        // with the original and with the clone. 
        Console.WriteLine("DTFI/NFI PROPERTY\tORIGINAL\tMODIFIED CLONE");
        Console.WriteLine("DTFI.AMDesignator\t{0}\t\t{1}", 
            myCI.get_DateTimeFormat().get_AMDesignator(), 
            myCIclone.get_DateTimeFormat().get_AMDesignator());
        Console.WriteLine("DTFI.DateSeparator\t{0}\t\t{1}", 
            myCI.get_DateTimeFormat().get_DateSeparator(), 
            myCIclone.get_DateTimeFormat().get_DateSeparator());
        Console.WriteLine("NFI.CurrencySymbol\t{0}\t\t{1}", 
            myCI.get_NumberFormat().get_CurrencySymbol(), 
            myCIclone.get_NumberFormat().get_CurrencySymbol());
        Console.WriteLine("NFI.NumberDecimalDigits\t{0}\t\t{1}",
            System.Convert.ToString(
            myCI.get_NumberFormat().get_NumberDecimalDigits()), 
            System.Convert.ToString(
            myCIclone.get_NumberFormat().get_NumberDecimalDigits()));
    } //main
} //SamplesCultureInfo

/*
This code produces the following output.

DTFI/NFI PROPERTY       ORIGINAL        MODIFIED CLONE
DTFI.AMDesignator       AM              a.m.
DTFI.DateSeparator      /               -
NFI.CurrencySymbol      $               USD
NFI.NumberDecimalDigits 2               4
*/

플랫폼

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

.NET Framework에서 모든 플래폼의 모든 버전을 지원하지는 않습니다. 지원되는 버전의 목록은 시스템 요구 사항을 참조하십시오.

버전 정보

.NET Framework

2.0, 1.1, 1.0에서 지원

.NET Compact Framework

2.0, 1.0에서 지원

참고 항목

참조

CultureInfo 클래스
CultureInfo 멤버
System.Globalization 네임스페이스
DateTimeFormatInfo
GetFormat
NumberFormat