ManagementDateTimeConverter.ToDmtfDateTime(DateTime) メソッド

定義

指定された DateTime を DMTF 日付時刻書式に変換します。

public:
 static System::String ^ ToDmtfDateTime(DateTime date);
public static string ToDmtfDateTime (DateTime date);
static member ToDmtfDateTime : DateTime -> string
Public Shared Function ToDmtfDateTime (date As DateTime) As String

パラメーター

date
DateTime

DMTF 書式に変換する日付時刻を表す DateTime

戻り値

指定された DateTime の DMTF 日付時刻を表す文字列。

次の例では、 を DateTime DMTF datetime 形式に変換します。

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

注釈

結果として得られる DMTF datetime 文字列は、現在のタイム ゾーンの UTC オフセットに基づきます。 DMTF の最も低い精度はマイクロ秒です。では DateTime、最も低い精度は です Ticks。これは 100 ナノ秒に相当します。 変換時に、 Ticks はマイクロ秒に変換され、最も近いマイクロ秒に丸められます。

.NET Framework のセキュリティ

直前の呼び出し元に対する完全な信頼。 このメンバーは、部分的に信頼されているコードから使用することはできません。 詳細については、「 部分信頼コードからのライブラリの使用」を参照してください。

適用対象