"t" and "tt" Custom Format Specifier in LightSwitch 2012

This article shows the differences and the use of the "t" and "tt" Custom Format Specifiers in LightSwitch Visual Studio 2012.

"t" Custom Format Specifier

The "t" Custom Format Specifier represents the first character of the AM/PM designator. This designator is fetched from
the DateTimeFormatInfo.AMDesignator or DateTimeFormatInfo.AMDesignator Property.

Note: If the "t" format specifier is used without any custom format specifier
then the "t" format specifier is considered to be a "Standard Date and Time Format Specifier".

"tt" Custom Format Specifier

The "tt" Custom Format Specifier represents the entire AM/PM designator. This name of week is fetched from the DateTimeFormatInfo.DayNames Property.

For both, the format Specifier
AM designator specifies an entire time duration from 0:00:00 (midnight) to 11:59:59:999 and the PM designator is used for an entire time duration from 12:00:00 (noon) to 23:59:59:999.

Use the following procedure to create a sample showing how to use the "t" and "tt" Custom Format Specifiers on a Screen.

Step 1

Open the LightSwitch Application in Visual Studio 2012 and go to the Solution Explorer.

Solution Explorer

Right-click on "Data Sources" and choose "Add Table".

Add Table

The table appears in the Table Designer window. Insert the records in the following table.

Employee Table

Step 2

Now once again go to the Solution Explorer, right-click on "Screens" and choose "Add Screen".

Add Screen

The Add New Screen dialog box appears. Select the "Editable Grid Screen" from the Screen Template, inside screen information, choose "Employee" under screen data and provide some name to the Screen and click the "OK" button.

Add New Screen

The Screen Designer appears as shown below.

Screen Designer

Press F5 to run the application. Provide the information; we will get the following output. 

Output of Editable Grid Screen

Step 3

Now stop debugging the application. From the Table Designer select the "DOB" record as shown in the figure below.

Select DOB from Employee.jpg

Then go to the Format Pattern of Property window in the Table Designer and enter "t" in the format pattern property as shown below. Here the "t" format specifier is considered to be a "Standard Date and Time Format Specifier". Hence it represents a short time pattern.


t Format Pattern Property

Once again press F5 to run the application. This time we will get the following output.

output using t format pattern

Step 4

Once again stop debugging the application and 
select the "DOB" record from the table.

Now go to the Format Pattern of the Property window in the Table Designer and this time enter "t dd" in the format pattern property as shown below.

t dd format pattern property

Once again press F5 to run the application. This time we will get the following output.
Now we get  the first character of the AM/PM designator.

output using t dd format pattern

Step 5

Once again stop debugging the application and go to the Format Pattern of Property window in the Table Designer and this time enter "tt" in the format pattern property as shown below.

tt format pattern property

Once again press F5 in order to run the application. This time we will get the following output. Now this time we get an
entire AM/PM designator.

output using tt format pattern

Up Next
    Ebook Download
    View all
    Learn
    View all