Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save SalesforceBobLightning/02a3a7eeac5ff26c15e845b83c2a04d8 to your computer and use it in GitHub Desktop.

Select an option

Save SalesforceBobLightning/02a3a7eeac5ff26c15e845b83c2a04d8 to your computer and use it in GitHub Desktop.
Apex Date & DateTime Formatting Helpers
// 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