Visualforce components for rendering a locale aware date or datetime value within a Visualforce page.
src/
+-- classes/
¦ +-- localeFormattedDate.cls
¦ +-- localeFormattedDateTest.cls
¦ +-- localeFormattedDatetime.cls
¦ +-- localeFormattedDatetimeTest.cls
+-- components/
¦ +-- localeFormattedDate.component
¦ +-- localeFormattedDatetime.component
+-- pages/
+-- localeFormattedSample.page
- localeFormattedDate: controller for localeFormattedDate
- localeFormattedDateTest: unit tests for localeFormattedDate.cls
- localeFormattedDatetime: controller for localeFormattedDatetime
- localeFormattedDatetimeTest: unit tests for localeFormattedDatetime.cls
- localeFormattedDate: Properly renders Date value based upon the running Uer's locale
- localeFormattedDatetime: Properly renders Datetime value based upon the running Uer's locale
- localeFormattedSample: Sample page for illustrating how to use the code
Deploy this code directly using "Deploy to Salesforce"
- Navigate to Setup > Develop > Apex Classes.
- Click the New button on that page.
- Copy and paste the code for localeFormattedDate.cls.
- Click the Save button.
Repeat above steps for remaining three (3) classes.
- Navigate to Setup > Develop > Components.
- Click the New button on that page.
- Copy and paste the code for localeFormattedDate.component.
Repeat above steps for remaining Visualforce component.
The "localeFormattedSample" Visualforce page is included to show you how to use the components.
<c:localeFormattedDate dateProvided="{!Today()}"></c:localeFormattedDate>
<c:localeFormattedDatetime datetimeProvided="{!Now()}"></c:localeFormattedDatetime>