Short Time ("t") Pattern and Long Time ("T") Pattern in LightSwitch 2012

This article describes how to use the Short Time Format Pattern and Long Time Format Pattern in LightSwitch Visual Studio 2012.

Short Time ("t") Format Specifier

The "t" format specifier represents a custom date and time format string. For example, the format string for the culture is "HH:mm".

Long Time ("T") Format Specifier

The "T" format specifier represents a custom date and time format string. For example, the format string for the culture is "HH:mm:ss".

Note that the Date Time Picker and the Date Time Viewer control will ignore the Format Pattern property. Only the TextBox and the Label controls will recognize this property.

Use the following procedure to create a sample showing how to use 
the Short Time Format Pattern and Long Time Format Pattern 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 into 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

Step 3

Press F5 to run the application. Provide the information. 

output of editable Screen

Step 4

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

Select DOJ from Employee

Then go to the Format Pattern of Property window in the table designer and enter the Short Time 
("t") in the format pattern as shown below.

t Format Pattern Properties

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

Output for Short Time Pattern

Step 5

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

Select DOJ from Employee

Then go to the Format Pattern of the Property window in the Table Designer and enter the Long Time 
("T") in the format pattern as shown below.

T format Pattern property window

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

Output for Long Time pattern


Similar Articles