📌  相关文章
📜  计算 apex salesforce 中两个日期之间的差异 - 无论代码示例

📅  最后修改于: 2022-03-11 15:00:21.048000             🧑  作者: Mango

代码示例1
DateTime startDate = DateTime.newInstance(2020,1,1,3,0,0);
DateTime endDate = DateTime.newInstance(2020,1,3,6,0,0);
 
Decimal minutes = Integer.valueOf((endDate.getTime() - startDate.getTime())/(1000*60));
System.debug('Minutes : ' + minutes);
 
Decimal hours = Integer.valueOf((endDate.getTime() - startDate.getTime())/(1000*60*60));
System.debug('Hours : ' + hours);
 
Decimal days = Integer.valueOf((endDate.getTime() - startDate.getTime())/(1000*60*60*24));
System.debug('Days : ' + days);