Wednesday, May 25, 2022

Convert Date into Long Time String in Salesforce Apex

  • First convert the date feild into the datetime field format
  • The getTime() in the datetime class will returns the number of milliseconds of a given date starting from  January 1, 1970, 00:00:00 GMT.

Source Code:

Date todayDate =;
DateTime todayDateTime = DateTime.newInstance(todayDate.year(),todayDate.month(),;
string longTime =String.valueOf(todayDateTime.getTime());
System.debug('Date in long time string..'+logTime);

Hope this helps you..Enjoy..!

Please comment or write us if you have any queries/requirements.

Please like,follow,bookmark,subscribe this site to receive daily updates.

No comments:

Post a Comment