Created
July 19, 2018 12:49
-
-
Save SalesforceBobLightning/02a3a7eeac5ff26c15e845b83c2a04d8 to your computer and use it in GitHub Desktop.
Apex Date & DateTime Formatting Helpers
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Useful Apex snippets for formatting date and datetime to String | |
| String value = String.format('{0}T00:00:00', new List<String> {DateTime.newInstance(Date.today(), Time.newInstance(0, 0, 0, 0)).format('YYYY-MM-dd')}); | |
| System.debug(value); | |
| // expected output: | |
| // YYYY-MM-ddT00:00:00 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment