GlobalTester CustomDateFormat Class
CustomDateFormat Members
Defines how date values are formatted and displayed for the current user.
Constructor
| Name | Description | |
|
|
CustomDateFormat | This class contains methods to set custom conventions for dates. |
Methods
| Name | Description | |
|
|
ChangeShortDateFormat(string) | Changes the short date formatting string. The maximum number of characters allowed for this string is 80, including a terminating null character. The string can consist of a combination of day, month, year, and era format pictures and any string of characters enclosed in single quotes. Characters in single quotes remain as specified. For example, the Spanish (Spain) long date is "dddd, dd' de 'MMMM' de 'yyyy". Locales can define multiple long date formats. |
|
|
ChangeLongDateFormat(string) | Changes the long date formatting string. The maximum number of characters allowed for this string is 80, including a terminating null character. The string can consist of a combination of day, month, year, and era format pictures and any string of characters enclosed in single quotes. Characters in single quotes remain as specified. For example, the Spanish (Spain) long date is "dddd, dd' de 'MMMM' de 'yyyy". Locales can define multiple long date formats. |
|
|
ChangeFirstDayOfWeek(FirstDayOfWeek) | Changes the First day of week value. The value must be selected from FirstDayOfWeek enumeration. |
Enumeration
| Name | Description | |
|
|
FirstDayOfWeek | Days of week; Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday. |
Exceptions
| Exception | Condition |
| ArgumentOutOfRange | The short date or long date format picture argument value exceeds the allowable range. |
Remarks
These methods customize the Time Formats on the Regional and Language control panel Time property sheet shown below.

Example
| namespace CustomizeDateSettingsExampleScript { using System; using System.Globalization; using TestingMentor.TestTool.GlobalTester; class MyTest { static void Main() { try { CustomDateFormat time = new CustomDateFormat(); string defaultLongDateFormat = CultureInfo.CurrentCulture.DateTimeFormat.LongDatePattern; string newLongDateFormat = "MMM - d (yyyy) gg"; if (time.ChangeLongDateFormat(newLongDateFormat)) { // Launch AUT // Execute test - (e.g. AUT implements long date string) // Oracle - (e.g. compare long date format used in AUT against customized pattern) // Reset test platform to original configuration time.ChangeLongDateFormat(defaultLongDateFormat); } else { // Date format not changed; test not executed (e.g. invalid // day, month, year, and era format pictures) } } catch(ArgumentOutOfRange e) { // Test script failure - (e.g. long date format string argument out of range) } finally { // Log test results } } } } |
This example illustrates how customized date settings might be used in test automation to determine whether the AUT correctly implements the Windows NLS APIs and allows users to customize locale national conventions. After the test is complete the date format is reset to its default state.
References
Also See
CustomNumberFormat Class
CustomCurrencyFormat Class
CustomLocation Class
CustomTimeFormat Class





