DateTimeOffset.Parse 方法

定義

將日期和時間的指定字串表示,轉換為其相等的 DateTimeOffsetConverts the specified string representation of a date and time to its DateTimeOffset equivalent.

多載

Parse(String)

將日期、時間和位移的指定字串表示,轉換為其相等的 DateTimeOffsetConverts the specified string representation of a date, time, and offset to its DateTimeOffset equivalent.

Parse(String, IFormatProvider)

使用指定的特定文化特性格式資訊,將日期和時間的指定字串表示轉換為其相等的 DateTimeOffsetConverts the specified string representation of a date and time to its DateTimeOffset equivalent using the specified culture-specific format information.

Parse(ReadOnlySpan<Char>, IFormatProvider, DateTimeStyles)

使用指定的特定文化特性格式資訊和格式樣式,將日期和時間的指定範圍表示轉換為其對等的 DateTimeOffsetConverts the specified span representation of a date and time to its DateTimeOffset equivalent using the specified culture-specific format information and formatting style.

Parse(String, IFormatProvider, DateTimeStyles)

使用指定的特定文化特性格式資訊和格式樣式,將日期和時間的指定字串表示轉換為其相等的 DateTimeOffsetConverts the specified string representation of a date and time to its DateTimeOffset equivalent using the specified culture-specific format information and formatting style.

備註

重要

日本曆法的紀元是以天皇的統治為基礎,因此有變更是正常的。Eras in the Japanese calendars are based on the emperor's reign and are therefore expected to change. 例如,2019 年 5 月 1 日之後,JapaneseCalendarJapaneseLunisolarCalendar 中將開始使用「令和」。For example, May 1, 2019 marked the beginning of the Reiwa era in the JapaneseCalendar and JapaneseLunisolarCalendar. 此變更對使用這些日曆的所有應用程式都有影響。Such a change of era affects all applications that use these calendars. 若要取得詳細資訊及判斷您的應用程式是否受影響,請參閱 Handling a new era in the Japanese calendar in .NET (處理 .NET 中日本日曆的新紀元)。See Handling a new era in the Japanese calendar in .NET for more information and to determine whether your applications are affected. 若要了解如何在 Windows 系統上測試您的應用程式,確保其已準備好面對紀元變更,請參閱 Prepare your application for the Japanese era change (讓應用程式準備好因應日本紀元變更)。See Prepare your application for the Japanese era change for information on testing your applications on Windows systems to ensure their readiness for the era change. 請參閱使用紀年以了解 .NET 中支援使用多種紀年的日曆,以及在處理支援多種紀年的日曆時能採用最佳做法。See Working with eras for features in .NET that support calendars with multiple eras and for best practices when working with calendars that support multiple eras.

Parse(String)

將日期、時間和位移的指定字串表示,轉換為其相等的 DateTimeOffsetConverts the specified string representation of a date, time, and offset to its DateTimeOffset equivalent.

public:
 static DateTimeOffset Parse(System::String ^ input);
public static DateTimeOffset Parse (string input);
static member Parse : string -> DateTimeOffset
Public Shared Function Parse (input As String) As DateTimeOffset

參數

input
String

字串,包含要轉換的日期和時間。A string that contains a date and time to convert.

傳回

DateTimeOffset

物件,與 input 中包含的日期和時間相等。An object that is equivalent to the date and time that is contained in input.

例外狀況

位移大於 14 小時或小於 -14 小時。The offset is greater than 14 hours or less than -14 hours.

inputnullinput is null.

input 不包含日期與時間的有效字串表示。input does not contain a valid string representation of a date and time.

-或--or- input 包含不含日期或時間之位移值的字串表示。input contains the string representation of an offset value without a date or time.

範例

下列範例會呼叫 Parse(String) 方法來剖析數個日期和時間字串。The following example calls the Parse(String) method to parse several date and time strings. 此範例包含2007年3月22日的輸出,該系統的文化特性為 en-us。The example includes output from March 22, 2007, on a system whose culture is en-us.

string dateString;
DateTimeOffset offsetDate;

// String with date only
dateString = "05/01/2008";
offsetDate = DateTimeOffset.Parse(dateString);
Console.WriteLine(offsetDate.ToString());

// String with time only
dateString = "11:36 PM";
offsetDate = DateTimeOffset.Parse(dateString);
Console.WriteLine(offsetDate.ToString());

// String with date and offset
dateString = "05/01/2008 +1:00";
offsetDate = DateTimeOffset.Parse(dateString);
Console.WriteLine(offsetDate.ToString());

// String with day abbreviation
dateString = "Thu May 01, 2008";
offsetDate = DateTimeOffset.Parse(dateString);
Console.WriteLine(offsetDate.ToString());
Dim dateString As String
Dim offsetDate As DateTimeOffset

' String with date only
dateString = "05/01/2008"
offsetDate = DateTimeOffset.Parse(dateString)
Console.WriteLine(offsetDate.ToString())   ' Displays 5/1/2008 12:00:00 AM -07:00  

' String with time only
dateString = "11:36 PM"
offsetDate = DateTimeOffset.Parse(dateString)
Console.WriteLine(offsetDate.ToString())   ' Displays 3/26/2007 11:36:00 PM -07:00

' String with date and offset 
dateString = "05/01/2008 +7:00"
offsetDate = DateTimeOffset.Parse(dateString)
Console.WriteLine(offsetDate.ToString())   ' Displays 5/1/2008 12:00:00 AM +07:00

' String with day abbreviation
dateString = "Thu May 01, 2008"
offsetDate = DateTimeOffset.Parse(dateString)
Console.WriteLine(offsetDate.ToString())   ' Displays 5/1/2008 12:00:00 AM -07:00

備註

Parse(String) 使用三個可依任何順序出現並以空白字元分隔的元素來剖析字串。Parse(String) parses a string with three elements that can appear in any order and are delimited by white space. 下列三個元素如下表所示。These three elements are as shown in the following table.

元素Element 範例Example
<Date> "2/10/2007""2/10/2007"
<Time> "1:02:03 PM""1:02:03 PM"
<Offset> "-7:30""-7:30"

雖然每個元素都是選擇性的,但 <Offset> 不能單獨出現。Although each of these elements is optional, <Offset> cannot appear by itself. 它必須與或一起提供 <Date> <Time> 。It must be provided together with either <Date> or <Time>. 如果 <Date> 遺失,則其預設值為目前的日期。If <Date> is missing, its default value is the current day. 如果 <Time> 遺失,則其預設值為 12:00:00 AM。If <Time> is missing, its default value is 12:00:00 AM. 如果 <Date> 存在,但其 year 元件僅包含兩位數,則會根據屬性的值,將它轉換成目前文化特性目前行事曆中的年份 Calendar.TwoDigitYearMaxIf <Date> is present but its year component consists of only two digits, it is converted to a year in the current culture's current calendar based on the value of the Calendar.TwoDigitYearMax property. 如果 <Offset> 遺失,則其預設值為本地時區的位移。If <Offset> is missing, its default value is the offset of the local time zone. <Offset> 可以代表國際標準時間 (UTC) 的負或正位移。<Offset> can represent either a negative or a positive offset from Coordinated Universal Time (UTC). 無論是哪一種情況,都 <Offset> 必須包含正負號符號。In either case, <Offset> must include a sign symbol.

input使用 DateTimeFormatInfo 針對目前文化特性初始化之物件中的格式資訊,來剖析字串。The input string is parsed by using the formatting information in a DateTimeFormatInfo object that is initialized for the current culture. 若要剖析包含指定格式的字串,而不一定會對應到目前文化特性的格式,請使用 ParseExact 方法並提供格式規範。To parse a string that contains designated formatting that does not necessarily correspond to the formatting of the current culture, use the ParseExact method and provide a format specifier.

另請參閱

適用於

Parse(String, IFormatProvider)

使用指定的特定文化特性格式資訊,將日期和時間的指定字串表示轉換為其相等的 DateTimeOffsetConverts the specified string representation of a date and time to its DateTimeOffset equivalent using the specified culture-specific format information.

public:
 static DateTimeOffset Parse(System::String ^ input, IFormatProvider ^ formatProvider);
public static DateTimeOffset Parse (string input, IFormatProvider formatProvider);
public static DateTimeOffset Parse (string input, IFormatProvider? formatProvider);
static member Parse : string * IFormatProvider -> DateTimeOffset
Public Shared Function Parse (input As String, formatProvider As IFormatProvider) As DateTimeOffset

參數

input
String

字串,包含要轉換的日期和時間。A string that contains a date and time to convert.

formatProvider
IFormatProvider

提供關於 input 之特定文化特性格式資訊的物件。An object that provides culture-specific format information about input.

傳回

DateTimeOffset

物件,與 input 中包含的日期和時間相等,如 formatProvider 所指定。An object that is equivalent to the date and time that is contained in input, as specified by formatProvider.

例外狀況

位移大於 14 小時或小於 -14 小時。The offset is greater than 14 hours or less than -14 hours.

inputnullinput is null.

input 不包含日期與時間的有效字串表示。input does not contain a valid string representation of a date and time.

-或--or- input 包含不含日期或時間之位移值的字串表示。input contains the string representation of an offset value without a date or time.

範例

下列範例會剖析為 fr-fr 文化特性格式化的日期和時間字串,並使用本機系統的預設 en-us 文化特性加以顯示。The following example parses date and time strings that are formatted for the fr-fr culture and displays them using the local system's default en-us culture.

DateTimeFormatInfo fmt = new CultureInfo("fr-fr").DateTimeFormat;
string dateString;
DateTimeOffset offsetDate;

dateString = "03-12-07";
offsetDate = DateTimeOffset.Parse(dateString, fmt);
Console.WriteLine("{0} returns {1}",
                  dateString,
                  offsetDate.ToString());

dateString = "15/09/07 08:45:00 +1:00";
offsetDate = DateTimeOffset.Parse(dateString, fmt);
Console.WriteLine("{0} returns {1}",
                  dateString,
                  offsetDate.ToString());

dateString = "mar. 1 janvier 2008 1:00:00 +1:00";
offsetDate = DateTimeOffset.Parse(dateString, fmt);
Console.WriteLine("{0} returns {1}",
                  dateString,
                  offsetDate.ToString());
// The example displays the following output to the console:
//    03-12-07 returns 12/3/2007 12:00:00 AM -08:00
//    15/09/07 08:45:00 +1:00 returns 9/15/2007 8:45:00 AM +01:00
//    mar. 1 janvier 2008 1:00:00 +1:00 returns 1/1/2008 1:00:00 AM +01:00
Dim fmt As DateTimeFormatInfo = New CultureInfo("fr-fr").DateTimeFormat
Dim dateString As String
Dim offsetDate As DateTimeOffset

dateString = "03-12-07"
offsetDate = DateTimeOffset.Parse(dateString, fmt)
Console.WriteLine("{0} returns {1}", _
                  dateString, _
                  offsetDate.ToString())

dateString = "15/09/07 08:45:00 +1:00"
offsetDate = DateTimeOffset.Parse(dateString, fmt)
Console.WriteLine("{0} returns {1}", _
                  dateString, _
                  offsetDate.ToString())

dateString = "mar. 1 janvier 2008 1:00:00 +1:00" 
offsetDate = DateTimeOffset.Parse(dateString, fmt)
Console.WriteLine("{0} returns {1}", _
                  dateString, _
                  offsetDate.ToString())
' The example displays the following output to the console:
'    03-12-07 returns 12/3/2007 12:00:00 AM -08:00
'    15/09/07 08:45:00 +1:00 returns 9/15/2007 8:45:00 AM +01:00
'    mar. 1 janvier 2008 1:00:00 +1:00 returns 1/1/2008 1:00:00 AM +01:00                              

備註

這個方法會使用三個可依任何順序出現並以空白字元分隔的元素來剖析字串。This method parses a string with three elements that can appear in any order and are delimited by white space. 下表顯示這三個元素。These three elements are shown in the following table.

元素Element 範例Example
<Date> "2/10/2007""2/10/2007"
<Time> "1:02:03 PM""1:02:03 PM"
<Offset> "-7:30""-7:30"

雖然每個元素都是選擇性的,但 <Offset> 不能單獨出現。Although each of these elements is optional, <Offset> cannot appear by itself. 它必須與或一起提供 <Date> <Time> 。It must be provided together with either <Date> or <Time>. 如果 <Date> 遺失,則其預設值為目前的日期。If <Date> is missing, its default value is the current day. 如果 <Date> 存在,但其 year 元件僅包含兩位數,則會根據屬性的值,將它轉換成參數目前行事曆中的年份 provider Calendar.TwoDigitYearMaxIf <Date> is present but its year component consists of only two digits, it is converted to a year in the provider parameter's current calendar based on the value of the Calendar.TwoDigitYearMax property. 如果 <Time> 遺失,則其預設值為 12:00:00 AM。If <Time> is missing, its default value is 12:00:00 AM. 如果 <Offset> 遺失,則其預設值為本地時區的位移。If <Offset> is missing, its default value is the offset of the local time zone. <Offset> 可以代表國際標準時間 (UTC) 的負或正位移。<Offset> can represent either a negative or a positive offset from Coordinated Universal Time (UTC). 無論是哪一種情況,都 <Offset> 必須包含正負號符號。In either case, <Offset> must include a sign symbol.

這三個元素的格式是由參數定義的 formatProvider ,它可以是下列其中一項:The format of these three elements is defined by the formatProvider parameter, which can be either of the following:

如果 formatprovidernull ,則 CultureInfo 會使用對應至目前文化特性的物件。If formatprovider is null, the CultureInfo object that corresponds to the current culture is used.

在中使用的正號或負號 <Offset> 必須是 + 或-。The positive or negative sign used in <Offset> must be either + or -. 它不是由 PositiveSign 參數物件的或屬性所定義 NegativeSign NumberFormatInfo formatProviderIt is not defined by the PositiveSign or NegativeSign properties of the NumberFormatInfo object of the formatProvider parameter.

另請參閱

適用於

Parse(ReadOnlySpan<Char>, IFormatProvider, DateTimeStyles)

使用指定的特定文化特性格式資訊和格式樣式,將日期和時間的指定範圍表示轉換為其對等的 DateTimeOffsetConverts the specified span representation of a date and time to its DateTimeOffset equivalent using the specified culture-specific format information and formatting style.

public static DateTimeOffset Parse (ReadOnlySpan<char> input, IFormatProvider? formatProvider = default, System.Globalization.DateTimeStyles styles = System.Globalization.DateTimeStyles.None);
public static DateTimeOffset Parse (ReadOnlySpan<char> input, IFormatProvider formatProvider = default, System.Globalization.DateTimeStyles styles = System.Globalization.DateTimeStyles.None);
static member Parse : ReadOnlySpan<char> * IFormatProvider * System.Globalization.DateTimeStyles -> DateTimeOffset
Public Shared Function Parse (input As ReadOnlySpan(Of Char), Optional formatProvider As IFormatProvider = Nothing, Optional styles As DateTimeStyles = System.Globalization.DateTimeStyles.None) As DateTimeOffset

參數

input
ReadOnlySpan<Char>

包含字元的範圍,其表示要轉換的日期和時間。A span containing the characters that represent a date and time to convert.

formatProvider
IFormatProvider

提供關於 input 之特定文化特性格式資訊的物件。An object that provides culture-specific format information about input.

styles
DateTimeStyles

列舉值的位元組合,其表示 input 所允許的格式。A bitwise combination of enumeration values that indicates the permitted format of input. 一般會指定的值是 NoneA typical value to specify is None.

傳回

DateTimeOffset

物件,與 input 中包含的日期和時間相等,如 formatProviderstyles 所指定。An object that is equivalent to the date and time that is contained in input as specified by formatProvider and styles.

適用於

Parse(String, IFormatProvider, DateTimeStyles)

使用指定的特定文化特性格式資訊和格式樣式,將日期和時間的指定字串表示轉換為其相等的 DateTimeOffsetConverts the specified string representation of a date and time to its DateTimeOffset equivalent using the specified culture-specific format information and formatting style.

public:
 static DateTimeOffset Parse(System::String ^ input, IFormatProvider ^ formatProvider, System::Globalization::DateTimeStyles styles);
public static DateTimeOffset Parse (string input, IFormatProvider formatProvider, System.Globalization.DateTimeStyles styles);
public static DateTimeOffset Parse (string input, IFormatProvider? formatProvider, System.Globalization.DateTimeStyles styles);
static member Parse : string * IFormatProvider * System.Globalization.DateTimeStyles -> DateTimeOffset
Public Shared Function Parse (input As String, formatProvider As IFormatProvider, styles As DateTimeStyles) As DateTimeOffset

參數

input
String

字串,包含要轉換的日期和時間。A string that contains a date and time to convert.

formatProvider
IFormatProvider

提供關於 input 之特定文化特性格式資訊的物件。An object that provides culture-specific format information about input.

styles
DateTimeStyles

列舉值的位元組合,其表示 input 所允許的格式。A bitwise combination of enumeration values that indicates the permitted format of input. 一般會指定的值是 NoneA typical value to specify is None.

傳回

DateTimeOffset

物件,與 input 中包含的日期和時間相等,如 formatProviderstyles 所指定。An object that is equivalent to the date and time that is contained in input as specified by formatProvider and styles.

例外狀況

位移大於 14 小時或小於 -14 小時。The offset is greater than 14 hours or less than -14 hours.

-或--or- styles 不是有效的 DateTimeStyles 值。styles is not a valid DateTimeStyles value.

-或--or- styles 包含不支援的 DateTimeStyles 值。styles includes an unsupported DateTimeStyles value.

-或--or- styles 包含無法搭配使用的 DateTimeStyles 值。styles includes DateTimeStyles values that cannot be used together.

inputnullinput is null.

input 不包含日期與時間的有效字串表示。input does not contain a valid string representation of a date and time.

-或--or- input 包含不含日期或時間之位移值的字串表示。input contains the string representation of an offset value without a date or time.

範例

下列範例說明將 DateTimeStyles.AssumeLocalDateTimeStyles.AssumeUniversalDateTimeStyles.AdjustToUniversal 值傳遞給 styles 方法之參數 Parse(String, IFormatProvider, DateTimeStyles) 的效果。The following example illustrates the effect of passing the DateTimeStyles.AssumeLocal, DateTimeStyles.AssumeUniversal, and DateTimeStyles.AdjustToUniversal values to the styles parameter of the Parse(String, IFormatProvider, DateTimeStyles) method.

string dateString;
DateTimeOffset offsetDate;

dateString = "05/01/2008 6:00:00";
// Assume time is local
offsetDate = DateTimeOffset.Parse(dateString, null, DateTimeStyles.AssumeLocal);
Console.WriteLine(offsetDate.ToString());   // Displays 5/1/2008 6:00:00 AM -07:00

// Assume time is UTC
offsetDate = DateTimeOffset.Parse(dateString, null, DateTimeStyles.AssumeUniversal);
Console.WriteLine(offsetDate.ToString());   // Displays 5/1/2008 6:00:00 AM +00:00

// Parse and convert to UTC
dateString = "05/01/2008 6:00:00AM +5:00";
offsetDate = DateTimeOffset.Parse(dateString, null, DateTimeStyles.AdjustToUniversal);
Console.WriteLine(offsetDate.ToString());   // Displays 5/1/2008 1:00:00 AM +00:00
Dim dateString As String
Dim offsetDate As DateTimeOffset

dateString = "05/01/2008 6:00:00"
' Assume time is local 
offsetDate = DateTimeOffset.Parse(dateString, Nothing, DateTimeStyles.AssumeLocal)
Console.WriteLine(offsetDate.ToString())   ' Displays 5/1/2008 6:00:00 AM -07:00

' Assume time is UTC
offsetDate = DateTimeOffset.Parse(dateString, Nothing, DateTimeStyles.AssumeUniversal)
Console.WriteLine(offsetDate.ToString())   ' Displays 5/1/2008 6:00:00 AM +00:00

' Parse and convert to UTC 
dateString = "05/01/2008 6:00:00AM +5:00"
offsetDate = DateTimeOffset.Parse(dateString, Nothing, DateTimeStyles.AdjustToUniversal)
Console.WriteLine(offsetDate.ToString())   ' Displays 5/1/2008 1:00:00 AM +00:00

備註

這個方法會使用三個可依任何順序出現並以空白字元分隔的元素來剖析字串。This method parses a string with three elements that can appear in any order and are delimited by white space. 下表顯示這三個元素。These three elements are shown in the following table.

元素Element 範例Example
<Date> "2/10/2007""2/10/2007"
<Time> "1:02:03 PM""1:02:03 PM"
<Offset> "-7:30""-7:30"

雖然每個元素都是選擇性的,但 <Offset> 不能單獨出現。Although each of these elements is optional, <Offset> cannot appear by itself. 它必須與或一起提供 <Date> <Time> 。It must be provided together with either <Date> or <Time>. 如果 <Date> 遺失,則其預設值為目前的日期。If <Date> is missing, its default value is the current day. 如果 <Date> 存在,但其 year 元件僅包含兩位數,則會根據屬性的值,將它轉換成參數目前行事曆中的年份 provider Calendar.TwoDigitYearMaxIf <Date> is present but its year component consists of only two digits, it is converted to a year in the provider parameter's current calendar based on the value of the Calendar.TwoDigitYearMax property. 如果 <Time> 遺失,則其預設值為 12:00:00 AM。If <Time> is missing, its default value is 12:00:00 AM. 如果 <Offset> 遺失,則其預設值為本地時區的位移,或 TimeSpan.Zero 如果在 DateTimeStyles.AdjustToUniversal DateTimeStyles.AssumeUniversal 參數中指定或值,則為 stylesIf <Offset> is missing, its default value is the offset of the local time zone, or TimeSpan.Zero if either the DateTimeStyles.AdjustToUniversal or DateTimeStyles.AssumeUniversal value is specified in the styles parameter. 如果 <Offset> 存在,則可以代表國際標準時間 (UTC) 的負或正位移。If <Offset> is present, it can represent either a negative or a positive offset from Coordinated Universal Time (UTC). 無論是哪一種情況,都 <Offset> 必須包含正負號符號。In either case, <Offset> must include a sign symbol.

這三個元素的格式是由參數定義的 formatProvider ,它可以是下列其中一項:The format of these three elements is defined by the formatProvider parameter, which can be either of the following:

每個專案也可以用前置或尾端空白字元括住,且 <Date> 和 <Time> 元素可以包含內部空白字元 (例如 6: 00:00) 。Each element can also be enclosed by leading or trailing white space, and the <Date> and <Time> elements can include inner white space (such as 6: 00:00). 只有 <Offset> 元件不能包含內部空白字元。Only the <Offset> component cannot include inner white space.

如果 formatprovidernull ,則 CultureInfo 會使用對應至目前文化特性的物件。If formatprovider is null, the CultureInfo object that corresponds to the current culture is used.

在中使用的正號或負號 <Offset> 必須是 + 或-。The positive or negative sign used in <Offset> must be either + or -. 它不是由參數所 PositiveSign 傳回之物件的或屬性所定義 NegativeSign NumberFormatInfo formatProviderIt is not defined by the PositiveSign or NegativeSign properties of the NumberFormatInfo object returned by the formatProvider parameter.

下表顯示 System.Globalization.DateTimeStyles 支援的列舉成員。The following table shows the members of the System.Globalization.DateTimeStyles enumeration that are supported.

DateTimeStyles 成員DateTimeStyles member 描述Description
AdjustToUniversal 剖析由和所表示的字串 input (如有必要),並將其轉換為 UTC。Parses the string represented by input and, if necessary, converts it to UTC. 它相當於剖析字串,然後呼叫 DateTimeOffset.ToUniversalTime 傳回物件的方法 DateTimeOffsetIt is equivalent to parsing a string and then calling the DateTimeOffset.ToUniversalTime method of the returned DateTimeOffset object.
AllowInnerWhite 雖然有效,但會忽略此值。Although valid, this value is ignored. 和元素中允許使用內部空白字元 <Date> <Time> 。Inner white space is permitted in the <Date> and <Time> elements.
AllowLeadingWhite 雖然有效,但會忽略此值。Although valid, this value is ignored. 剖析字串中的每個元件前面都允許前置空白字元。Leading white space is permitted in front of each component in the parsed string.
AllowTrailingWhite 雖然有效,但會忽略此值。Although valid, this value is ignored. 剖析字串中的每個元件前面都允許尾端的空白字元。Trailing white space is permitted in front of each component in the parsed string.
AllowWhiteSpaces 此為預設行為。This is the default behavior. 您無法藉由提供更嚴格的列舉值(例如)來覆寫它 DateTimeStyles DateTimeStyles.NoneIt cannot be overridden by supplying a more restrictive DateTimeStyles enumeration value, such as DateTimeStyles.None.
AssumeLocal 指出如果 input 參數缺少 <Offset> 元素,則應提供當地時區的位移。Indicates that, if the input parameter lacks an <Offset> element, the offset of the local time zone should be provided. 這是方法的預設行為 ParseThis is the default behavior of the Parse method.
AssumeUniversal 指出如果 input 參數缺少 <Offset> 元素,則應提供 UTC 位移 (00:00) 。Indicates that, if the input parameter lacks an <Offset> element, the UTC offset (00:00) should be provided.
None 雖然有效,但這個值會被忽略,而且沒有任何作用。Although valid, this value is ignored and has no effect.
RoundtripKind 因為 DateTimeOffset 結構不包含 Kind 屬性,所以此值沒有任何作用。Because the DateTimeOffset structure does not include a Kind property, this value has no effect.

DateTimeStyles.NoCurrentDateDefault 支援值。Only the DateTimeStyles.NoCurrentDateDefault value is not supported. ArgumentException如果參數中包含此值,就會擲回 stylesAn ArgumentException is thrown if this value is included in the styles parameter.

另請參閱

適用於