ManagementDateTimeConverter.ToTimeSpan(String) 메서드

정의

지정된 DMTF 시간 간격을 TimeSpan으로 변환합니다.

public:
 static TimeSpan ToTimeSpan(System::String ^ dmtfTimespan);
public static TimeSpan ToTimeSpan (string dmtfTimespan);
static member ToTimeSpan : string -> TimeSpan
Public Shared Function ToTimeSpan (dmtfTimespan As String) As TimeSpan

매개 변수

dmtfTimespan
String

DMTF 시간 간격에 대한 문자열 표현입니다.

반환

지정된 DMTF 시간 간격을 나타내는 TimeSpan입니다.

예외

DMTF 시간 간격 값이 TimeSpan.MaxValue보다 큽니다.

예제

다음 예제에서는 지정 된 DMTF 시간 간격에 변환 TimeSpan합니다.

using System;
using System.Management;

// The sample below demonstrates the various conversions
// that can be done using ManagementDateTimeConverter class
class Sample_ManagementDateTimeConverterClass
{
    public static int Main(string[] args)
    {
        string dmtfDate = "20020408141835.999999-420";
        string dmtfTimeInterval = "00000010122532:123456:000";

        // Converting DMTF datetime to System.DateTime
        DateTime dt =
            ManagementDateTimeConverter.ToDateTime(dmtfDate);

        // Converting System.DateTime to DMTF datetime
        string dmtfDateTime =
            ManagementDateTimeConverter.ToDmtfDateTime(DateTime.Now);

        // Converting DMTF time interval to System.TimeSpan
        System.TimeSpan tsRet =
            ManagementDateTimeConverter.ToTimeSpan(dmtfTimeInterval);

        //Converting System.TimeSpan to DMTF time interval format
        System.TimeSpan ts =
            new System.TimeSpan(10,12,25,32,456);
        string dmtfTimeInt  =
            ManagementDateTimeConverter.ToDmtfTimeInterval(ts);

        return 0;
    }
}
Imports System.Management

'The sample below demonstrates the various conversions
' that can be done using ManagementDateTimeConverter class    
Class Sample_ManagementClass
    Public Overloads Shared Function Main(ByVal args() As String) _
        As Integer
        Dim dmtfDate As String = "20020408141835.999999-420"
        Dim dmtfTimeInterval As String = "00000010122532:123456:000"

        'Converting DMTF datetime and intervals to System.DateTime
        Dim dt As DateTime = _
            ManagementDateTimeConverter.ToDateTime(dmtfDate)

        'Converting System.DateTime to DMTF datetime
        dmtfDate = _
            ManagementDateTimeConverter.ToDmtfDateTime(DateTime.Now)

        ' Converting DMTF timeinterval to System.TimeSpan
        Dim tsRet As System.TimeSpan = _
            ManagementDateTimeConverter.ToTimeSpan(dmtfTimeInterval)

        'Converting System.TimeSpan to DMTF time interval format
        Dim ts As System.TimeSpan = _
            New System.TimeSpan(10, 12, 25, 32, 456)
        Dim dmtfTimeInt As String
        dmtfTimeInt = _
            ManagementDateTimeConverter.ToDmtfTimeInterval(ts)

        Return 0
    End Function
End Class

설명

.NET Framework 보안

직접 실행 호출자의 경우 완전히 신뢰합니다. 이 멤버는 부분적으로 신뢰할 수 있는 코드에서 사용할 수 없습니다. 자세한 내용은 부분적으로 신뢰할 수 있는 코드에서 라이브러리를 사용 하 여입니다.

적용 대상