Friday, 23 October 2015

How to remove time/timestamp from date in salesforce?

Here is the way to remove time/timestamp from date in salesforce,

Way 1:

  1. Date dt = System.Today();
  2. System.debug(dt.format());

Note: The above format() method returns the Date as a string using the locale of the context user.

Reference: Date Class

Way 2:

  1. Date dt = System.Today();
  2. System.debug(dt.day()+'/'+dt.month()+'/'+dt.year());

Note: You can adjust the format based on your need.

No comments:

Post a Comment

Activities: Assign Tasks to a Queue Salesforce Lightning

Salesforce announced to assign Tasks to a Queue beginning from Spring'20 release. How does it work? In Setup, enter Queues in th...