OdedCoster.com/blog

One day I will think of something clever to put here

Browsing Posts in DateTime

Date and Time format strings come in two flavors – standard and custom. Whenever these are used, the CultureInfo that is used with them comes into play. If an IFormatProvider is not specified, the CultureInfo assigned to the current thread is used. Standard format strings These are all single character format specifiers – they each [...]

If you wish to have a deterministic format, but do not want to use a specific culture, you can use InvariantCulture. InvariantCulture represents no culture at all – it is associated with the English language, though no specific country/region. See Using the InvariantCulture Property on MSDN. Here is an example of its use: DateTime dt [...]

As mentioned in my last post, the IFormatProvider interface in the context of DateTime is mostly used for formatting a DateTime to a specific representation and for parsing a string into a DateTime instance. Overloads that do not specify IFormatProvider So, what happens when overloads of ToString and the different Parse methods (Parse, TryParse, ParseExact [...]

Several of the overloads of ToString and the different Parse methods (Parse, ParseExact, TryParse and TryParseExact) defined on DateTime take an IFormatProvider parameter. This interface defines a single method – GetFormat which takes a type and returns an object that provides formatting services for the specified type. When DateTime in concerned this object would be [...]

One of the most common misunderstandings I see on StackOverflow regarding the DateTime structure is the difference between the value of a DateTime instance and how it is displayed. A DateTime instance (say one representing midnight of March 26th 2011) has an internal representation that has no specific formatting – it is not something that [...]