| DateTimeFormatInfo |
Formatting dates can vary greatly across multiple cultures. Each
culture can provide formatting information that is specific to itself. A DateTimeFormatInfo
object contains all the formatting information necessary to create a wide range of formatted
dates and times. Also, this class provides a Format method to allow for directly
formatting dates and times.
The following table lists standard formats to be used when formatting dates. The format characters are associated with the DateTimeFormatInfo' class in representing date formats. The characters are case-sensitive.'
This table is taken from Microsoft .NET 1.1 MSDN.'
| Format Character | Description and Associated Properties | '
|---|---|
| d | 'ShortDatePattern | '
| D | 'LongDatePattern | '
| f | 'Full Date and Time (Long Date and Short Time) | '
| F | 'FullDateTimePattern (Long Date and Long Time) | '
| g | 'General (Short Date and Short Time) | '
| G | 'General (Short Date and Long Time) | '
| m,M | 'MonthDayPattern | '
| r,R | 'RFC1123Pattern | '
| s | 'SortableDateTimePattern | '
| t | 'ShortTimePattern | 'T | 'LongTimePattern | ' '
| u | 'UniversalSortableDateTimePattern | '
| U | 'Full Date and Time (Long Date, Long Time) using universal time | '
| y,Y | 'YearMonthPattern | '
| Format Character | Description and Associated Properties | '
|---|---|
| d | 'The day of the month. Single-digit days will not have a leading zero. | '
| dd | 'The day of the month. Single-digit days will have a leading zero. | '
| ddd | 'The abbreviated name of the day of the week, as defined in AbbreviatedDayNames. | '
| dddd | 'The full name of the day of the week, as defined in DayNames. | '
| M | 'The numeric month. Single-digit months will not have a leading zero. | '
| MM | 'The numeric month. Single-digit months will have a leading zero. | '
| MMM | 'The abbreviated name of the month, as defined in AbbreviatedMonthNames. | '
| MMMM | 'The full name of the month, as defined in MonthNames. | '
| y | 'The year without the century. If the year without the century is less than 10, the year is displayed with no leading zero. | '
| yy | 'The year without the century. If the year without the century is less than 10, the year is displayed with a leading zero. | '
| yyyy | 'The year in four digits, including the century. | '
| h | 'The hour in a 12-hour clock. Single-digit hours will not have a leading zero. | '
| hh | 'The hour in a 12-hour clock. Single-digit hours will have a leading zero. | '
| H | 'The hour in a 24-hour clock. Single-digit hours will not have a leading zero. | '
| HH | 'The hour in a 24-hour clock. Single-digit hours will have a leading zero. | '
| m | 'The minute. Single-digit minutes will not have a leading zero. | '
| mm | 'The minute. Single-digit minutes will have a leading zero. | '
| s | 'The second. Single-digit seconds will not have a leading zero. | '
| ss | 'The second. Single-digit seconds will have a leading zero. | '
| f | 'The fraction of a second in single-digit precision. The remaining digits are truncated. | '
| ff | 'The fraction of a second in double-digit precision. The remaining digits are truncated. | '
| fff | 'The fraction of a second in three-digit precision. The remaining digits are truncated. | '
| ffff | 'The fraction of a second in four-digit precision. The remaining digits are truncated. | '
| fffff | 'The fraction of a second in five-digit precision. The remaining digits are truncated. | '
| ffffff | 'The fraction of a second in six-digit precision. The remaining digits are truncated. | '
| fffffff | 'The fraction of a second in seven-digit precision. The remaining digits are truncated. | '
| t | 'The first character in the AM/PM designator defined in AMDesignator or PMDesignator, if any. | '
| tt | 'The AM/PM designator defined in AMDesignator or PMDesignator, if any. | '
| z | 'The time zone offset ("+" or "-" followed by the hour only). Single-digit hours will not have a leading zero. For example, Pacific Standard Time is "-8". | '
| zz | 'The time zone offset ("+" or "-" followed by the hour only). Single-digit hours will have a leading zero. For example, Pacific Standard Time is "-08". | '
| zzz | 'The full time zone offset ("+" or "-" followed by the hour and minutes). Single-digit hours and minutes will have leading zeros. For example, Pacific Standard Time is "-08:00". | '
| : | 'The default time separator defined in TimeSeparator. | '
| / | 'The default date separator defined in DateSeparator. | '
| %c | 'Where c is a format pattern if used alone. The "%" character can be omitted if the format pattern is combined with literal characters or other format patterns. | '
| \c | 'Where c is any character. Displays the character literally. To display the backslash character, use "\\". | '
Project VBCorLib Overview | DateTimeFormatInfoStatic | ICloneable | IFormatProvider
| ICloneable | |
| IFormatProvider | |
| IObject |
| Name | Description |
|---|---|
AbbreviatedDayNames (get) | Returns an array of abbreviated weekday names. |
AbbreviatedDayNames (let) | Sets the weekday names to be used by this FormatProvider. |
AbbreviatedMonthNames (get) | Returns an array of names for all the months. |
AbbreviatedMonthNames (let) | Sets the abbreviated month names to be used by the formatter. |
AMDesignator (get) | Returns the string that is displayed for times from 12:00:00 AM to 11:59:59 AM. |
AMDesignator (let) | Sets the string that is display for times from 12:00:00 AM to 11:59:59 AM. |
Calendar (get) | Returns the Calendar associated with this DateTimeFormatInfo. |
Calendar (set) | Sets the calendar associated with this DateTimeFormatInfo. |
CalendarWeekRule (get) | Returns the definition of the first week of the calendar year. |
CalendarWeekRule (let) | Sets the definition of the first week for the calendar year. |
DateSeparator (get) | Returns the string that is displayed when separating the components of a date, such as year, month, day. |
DateSeparator (let) | Sets the string that is display when separating the components of a date, such as year, month, day. |
DayNames (get) | Returns the names of the weekdays. |
DayNames (let) | Sets the names for the weekdays. |
FirstDayOfWeek (get) | Returns the first day of the week. |
FirstDayOfWeek (let) | Sets the first day of the week. |
FullDateTimePattern (get) | Returns a formatting pattern that represents a full date and time associated with the F' formatting command. |
FullDateTimePattern (let) | Sets the formatting pattern used for a full date and time formatting, and is associated with the F' formatting command. |
IsReadOnly (get) | Returns if this formatter is ReadOnly. |
LongDatePattern (get) | Returns a pattern for formatting just the date portion and is associated with the D' formatting command. |
LongDatePattern (let) | Sets a pattern used for formatting just the date portion and is associated with the D' formatting command. |
LongTimePattern (get) | Returns a pattern used in formatting the time portion and is associated with the T' formatting command. |
LongTimePattern (let) | Sets the pattern used to format the time part when using the T' formatting command. |
MonthDayPattern (get) | Returns the month/day pattern associated with either m' or 'M' formatting commands. |
MonthDayPattern (let) | Sets the month/day formatting pattern associated with either m' or 'M' formatting commands. |
MonthNames (get) | Returns the full names for the months of the year. |
MonthNames (let) | Sets the full month names to be used by the formatter. |
PMDesignator (get) | Returns the string diplayed for times between 12:00:00 PM and 12:00:00 AM. |
PMDesignator (let) | Sets the string display for times between 12:00:00 PM and 12:00:00 AM. |
RFC1123Pattern (get) | Returns the pattern as specified by RFC-1123 and associated with the r' or 'R' formatting commands. |
ShortDatePattern (get) | Returns the pattern for short date formatting associated with the d' formatting command. |
ShortDatePattern (let) | Sets the pattern used in formatting dates with the d' formatting command. |
ShortTimePattern (get) | Returns the formatting pattern for a short time using the t' formatting command. |
ShortTimePattern (let) | Sets the formatting pattern for a short time using the t' formatting command. |
SortableDateTimePattern (get) | Returns a pattern that can be used in string sorting to produce an ascending sort with string based dates and times. This pattern is associated with the s' formatting command. |
TimeSeparator (get) | Returns the separator of time components, such as hours, minutes, seconds. |
TimeSeparator (let) | Set the separator for time components. |
UniversalSortableDateTimePattern (get) | Returns a string sortable pattern that is associated with the u' or 'U' formatting commands. |
YearMonthPattern (get) | Returns the pattern representing a YearMonth combination. This is associated with the y' or 'Y' formatting commands. |
YearMonthPattern (let) | Sets the pattern that represents a YearMonth combination. This is associated with the y' or 'Y' formatting commands. |
| Name | Description |
|---|---|
Clone | Returns a clone of this instance. If this instance is ReadOnly, the clone will also be ReadOnly. |
Equals | Returns a boolean indicating if the value and this object instance are the same instance. |
format | Formats a cDateTime object or Date value in the pattern specified by the formatting command. If no command is specified, then G' is assumed. If the command cannot be found, then a custom pattern is assumed. |
GetAbbreviatedDayName | Returns the abbreviated name for the specified day-of-the-week. |
GetAbbreviatedEraName | Returns the name of the Era specified. |
GetAbbreviatedMonthName | Retrieves the abbreviated name for a given month. |
GetAllDateTimePatterns | Returns all of the patterns for a specified formatting command. Or if no command is specified, then all of the patterns are returned. |
GetDayName | Returns the full name for the day of the week. |
GetEra | Returns the numeric era value based on the name provided. |
GetEraName | Returns the full name of the specified. |
GetFormat | Returns a format provider for the specified format type. |
GetHashCode | Returns a pseudo-unique number identifying this instance. |
GetMonthName | Returns the full name of the specified month. |
ToString | Returns a string representation of this object instance. |