ManagementDateTimeConverter.ToTimeSpan メソッド
アセンブリ: System.Management (system.management.dll 内)
構文Dim dmtfTimespan As String Dim returnValue As TimeSpan returnValue = ManagementDateTimeConverter.ToTimeSpan(dmtfTimespan)
戻り値
指定された DMTF 時間間隔を表す TimeSpan。
解説WMI の時間間隔は、DMTF 書式で表現されます。この書式については、WMI SDK のマニュアルに説明されています。DMTF 時間間隔の値が MaxValue の値より大きい場合は、ArgumentOutOfRangeException がスローされます。
.NET Framework のセキュリティ
使用例指定された DMTF 時間間隔を TimeSpan に変換する例を次に示します。
Imports System 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
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; } }
.NET Framework のセキュリティ
プラットフォームWindows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。
バージョン情報
参照- ManagementDateTimeConverter.ToTimeSpan メソッドのページへのリンク