public static DateTimeOffset? GetDateTimeOffsetFromString(string raw)
Parses the input string and returns DateTimeOffset if the input is
of the format "yyyy-MM-ddTHH:mm:ss.FFFZ" or "yyyy-MM-ddTHH:mm:ssZ". If the input is null,
this method returns null. Otherwise, FormatException is thrown.
public static string GetStringFromDateTimeOffset(DateTimeOffset? date)
Returns a string from the input DateTimeOffset instance, or null if
date is null. The string is always in the format "yyyy-MM-ddTHH:mm:ss.fffZ" or
"yyyy-MM-ddTHH:mm:ssZ" - always UTC, always either second or millisecond precision, and always using the
invariant culture.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-09-04 UTC."],[[["\u003cp\u003eThe \u003ccode\u003eUtilities\u003c/code\u003e class in the \u003ccode\u003eGoogle.Apis.Util\u003c/code\u003e namespace provides a collection of helper methods and extension methods for use in the Google.Apis library.\u003c/p\u003e\n"],["\u003cp\u003eThis class offers methods for checking argument conditions, such as \u003ccode\u003eCheckArgument\u003c/code\u003e and \u003ccode\u003eCheckEnumValue\u003c/code\u003e, to ensure data validity and throw exceptions when needed.\u003c/p\u003e\n"],["\u003cp\u003eIt includes methods for converting data types to and from strings, including \u003ccode\u003eConvertToString\u003c/code\u003e, \u003ccode\u003eDeserializeForGoogleFormat\u003c/code\u003e, and methods to handle \u003ccode\u003eDateTime\u003c/code\u003e and \u003ccode\u003eDateTimeOffset\u003c/code\u003e values.\u003c/p\u003e\n"],["\u003cp\u003eThe class has utilities to serialize and deserialize objects using Google's specific format, via the \u003ccode\u003eSerializeForGoogleFormat\u003c/code\u003e and \u003ccode\u003eDeserializeForGoogleFormat\u003c/code\u003e methods.\u003c/p\u003e\n"],["\u003cp\u003eIt provides extension methods, like \u003ccode\u003eThrowIfNullOrEmpty\u003c/code\u003e and \u003ccode\u003eThrowIfNull\u003c/code\u003e, for handling null or empty strings and null objects, throwing relevant exceptions if these conditions are met.\u003c/p\u003e\n"]]],[],null,["# Class Utilities (1.69.0)\n\nVersion latestkeyboard_arrow_down\n\n- [1.69.0 (latest)](/dotnet/docs/reference/Google.Apis/latest/Google.Apis.Util.Utilities)\n- [1.68.0](/dotnet/docs/reference/Google.Apis/1.68.0/Google.Apis.Util.Utilities)\n- [1.60.0](/dotnet/docs/reference/Google.Apis/1.60.0/Google.Apis.Util.Utilities)\n- [1.59.0](/dotnet/docs/reference/Google.Apis/1.59.0/Google.Apis.Util.Utilities)\n- [1.55.0](/dotnet/docs/reference/Google.Apis/1.55.0/Google.Apis.Util.Utilities)\n- [1.50.0](/dotnet/docs/reference/Google.Apis/1.50.0/Google.Apis.Util.Utilities) \n\n public static class Utilities\n\nA utility class which contains helper methods and extension methods. \n\nInheritance\n-----------\n\n[object](https://learn.microsoft.com/dotnet/api/system.object) \\\u003e Utilities \n\nInherited Members\n-----------------\n\n[object.Equals(object)](https://learn.microsoft.com/dotnet/api/system.object.equals#system-object-equals(system-object)) \n[object.Equals(object, object)](https://learn.microsoft.com/dotnet/api/system.object.equals#system-object-equals(system-object-system-object)) \n[object.GetHashCode()](https://learn.microsoft.com/dotnet/api/system.object.gethashcode) \n[object.GetType()](https://learn.microsoft.com/dotnet/api/system.object.gettype) \n[object.MemberwiseClone()](https://learn.microsoft.com/dotnet/api/system.object.memberwiseclone) \n[object.ReferenceEquals(object, object)](https://learn.microsoft.com/dotnet/api/system.object.referenceequals) \n[object.ToString()](https://learn.microsoft.com/dotnet/api/system.object.tostring)\n\nNamespace\n---------\n\n[Google.Apis.Util](/dotnet/docs/reference/Google.Apis/latest/Google.Apis.Util)\n\nAssembly\n--------\n\nGoogle.Apis.Core.dll\n\nMethods\n-------\n\n### CheckArgument\\\u003cT1, T2\\\u003e(bool, string, string, T1, T2)\n\n public static void CheckArgument\u003cT1, T2\u003e(bool condition, string paramName, string format, T1 arg0, T2 arg1)\n\nChecks that given argument-based condition is met, throwing an [ArgumentException](https://learn.microsoft.com/dotnet/api/system.argumentexception) otherwise.\n\n### CheckEnumValue\\\u003cT\\\u003e(T, string)\n\n public static T CheckEnumValue\u003cT\u003e(T value, string paramName) where T : struct\n\nChecks that the given value is in fact defined in the enum used as the type argument of the method.\n\n### ConvertToString(object)\n\n public static string ConvertToString(object o)\n\nTries to convert the specified object to a string. Uses custom type converters if available.\nReturns null for a null object.\n\n### DeserializeForGoogleFormat(string)\n\n public static object DeserializeForGoogleFormat(string rawValue)\n\nDeserializes the given raw value to an object using [Instance](/dotnet/docs/reference/Google.Apis/latest/Google.Apis.Json.NewtonsoftJsonSerializer#Google_Apis_Json_NewtonsoftJsonSerializer_Instance),\nas if it were a JSON string value.\n\n### GetCustomAttribute\\\u003cT\\\u003e(MemberInfo)\n\n public static T GetCustomAttribute\u003cT\u003e(this MemberInfo info) where T : Attribute\n\nA Google.Apis utility method for returning the first matching custom attribute (or `null`) of the specified member.\n\n### GetDateTimeFromString(string)\n\n public static DateTime? GetDateTimeFromString(string raw)\n\nParses the input string and returns [DateTime](https://learn.microsoft.com/dotnet/api/system.datetime) if the input is a valid\nrepresentation of a date. Otherwise it returns `null`.\n\n### GetDateTimeOffsetFromString(string)\n\n public static DateTimeOffset? GetDateTimeOffsetFromString(string raw)\n\nParses the input string and returns [DateTimeOffset](https://learn.microsoft.com/dotnet/api/system.datetimeoffset) if the input is\nof the format \"yyyy-MM-ddTHH:mm:ss.FFFZ\" or \"yyyy-MM-ddTHH:mm:ssZ\". If the input is null,\nthis method returns `null`. Otherwise, [FormatException](https://learn.microsoft.com/dotnet/api/system.formatexception) is thrown.\n\n### GetEnumStringValue(Enum)\n\n public static string GetEnumStringValue(Enum value)\n\nReturns the defined string value of an Enum. Use for test purposes or in other Google.Apis projects.\n\n### GetLibraryVersion()\n\n public static string GetLibraryVersion()\n\nReturns the version of the core library.\n\n### GetStringFromDateTime(DateTime?)\n\n public static string GetStringFromDateTime(DateTime? date)\n\nReturns a string (by RFC3339) form the input [DateTime](https://learn.microsoft.com/dotnet/api/system.datetime) instance.\n\n### GetStringFromDateTimeOffset(DateTimeOffset?)\n\n public static string GetStringFromDateTimeOffset(DateTimeOffset? date)\n\nReturns a string from the input [DateTimeOffset](https://learn.microsoft.com/dotnet/api/system.datetimeoffset) instance, or `null` if\n`date` is null. The string is always in the format \"yyyy-MM-ddTHH:mm:ss.fffZ\" or\n\"yyyy-MM-ddTHH:mm:ssZ\" - always UTC, always either second or millisecond precision, and always using the\ninvariant culture.\n\n### SerializeForGoogleFormat(object)\n\n public static string SerializeForGoogleFormat(object value)\n\nSerializes the given value using [Instance](/dotnet/docs/reference/Google.Apis/latest/Google.Apis.Json.NewtonsoftJsonSerializer#Google_Apis_Json_NewtonsoftJsonSerializer_Instance).\n\n### ThrowIfNullOrEmpty(string, string)\n\n public static string ThrowIfNullOrEmpty(this string str, string paramName)\n\nA Google.Apis utility method for throwing an [ArgumentNullException](https://learn.microsoft.com/dotnet/api/system.argumentnullexception) if the string is\n`null` or empty.\n\n### ThrowIfNull\\\u003cT\\\u003e(T, string)\n\n public static T ThrowIfNull\u003cT\u003e(this T obj, string paramName)\n\nA Google.Apis utility method for throwing an [ArgumentNullException](https://learn.microsoft.com/dotnet/api/system.argumentnullexception) if the object is\n`null`."]]