日本語PDF

explicit operator OracleDate(string)

このメソッドにより、指定した文字列がOracleDate構造に変換されます。

宣言

// C#
public explicit operator OracleDate (string dateStr);

パラメータ

  • dateStr

    Oracle DATEの文字列表現

戻り値

戻されたOracleDate構造には、文字列dateStrの日付および時間が含まれます。

例外

ArgumentNullException - dateStrはNULLです。

ArgumentException - この例外は次のいずれかの条件が存在する場合に表示されます。

  • dateStrはOracle DATEの無効な文字列表現です。

  • dateStrは、OracleのNLS_DATE_FORMATパラメータを表す、スレッドのOracleGlobalization.DateFormatプロパティによって指定される日付書式ではありません。

備考

月および日付に使用されている名称および略称は、スレッドのOracleGlobalizationオブジェクトのDateLanguageおよびCalendarプロパティで指定されている言語による表記です。スレッドのグローバリゼーション・プロパティのいずれかがNULLまたは空の文字列に設定されている場合、クライアントのコンピュータの設定が使用されます。

// C#
 
using System;
using Oracle.DataAccess.Client;
using Oracle.DataAccess.Types;
 
class OracleDateSample
{
  static void Main(string[] args)
  {
    // Set the thread's DateFormat to a specific format
    OracleGlobalization info = OracleGlobalization.GetClientInfo();
    info.DateFormat = "YYYY-MON-DD";
    OracleGlobalization.SetThreadInfo(info);
    
    // Construct OracleDate from a string using the DateFormat specified
    OracleDate date = (OracleDate)"1999-DEC-01";
    
    // Set a different DateFormat on the thread for ToString() 
    info.DateFormat = "MON DD YY";
    OracleGlobalization.SetThreadInfo(info);
 
    // Prints "DEC 01 99"
    Console.WriteLine(date.ToString()); 
  }
}