"gg" Custom Format Specifier in LightSwitch 2012

This article describes how to use the "gg" Custom Format Specifier in LightSwitch Visual Studio 2012.

"gg" Custom Format Specifier

The "gg" Custom Format Specifier is used to represent the period or the era (for Example, A.D.).

Note:
 It ignores this format specifier if the date to be formatted does not have an associated period or string. Suppose the "g" format specifier is used without other custom format specifiers, it is interpreted as the "g" standard date and time format specifier. 

Use the following procedure to create a sample showing how to use the "gg" Custom Format Specifier 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 DOJ from Employee

Then go to the Format Pattern of Property window in the Table Designer and enter "gg" in the format pattern for Universal Sortable Format Specifier as shown below.


gg Format Pattern properties

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

gg format pattern output

Step 4

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

Now go to the Format Pattern of Property window in the Table Designer and this time enter "ggg" in the format pattern for Universal Full Format Specifier as shown below.

ggg format pattern

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

gg format pattern output