Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/xpath/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在Apex Salesforce中将Unix时间转换为日期时间_Salesforce_Apex Code_Apex_Apex Trigger - Fatal编程技术网

在Apex Salesforce中将Unix时间转换为日期时间

在Apex Salesforce中将Unix时间转换为日期时间,salesforce,apex-code,apex,apex-trigger,Salesforce,Apex Code,Apex,Apex Trigger,我需要存储从对Salesforce DateTime的响应返回的时间戳。但是返回的时间戳是Unix格式的。 如何在Salesforce中使用apex将其转换为DateTime?尝试integer.valueOf而不是long.valueOf这是一个非常古老的问题,但我找到了答案 我从一个RESTAPI中获取了一些数据,该API将unix时间戳作为修改日期。我需要使用Salesforce中的Apex将unix时间戳转换为Datetime对象 我在以下位置找到此代码: 另外,请确保utcTime变量

我需要存储从对Salesforce DateTime的响应返回的时间戳。但是返回的时间戳是Unix格式的。
如何在Salesforce中使用apex将其转换为DateTime?

尝试integer.valueOf而不是long.valueOf

这是一个非常古老的问题,但我找到了答案

我从一个RESTAPI中获取了一些数据,该API将unix时间戳作为修改日期。我需要使用Salesforce中的Apex将unix时间戳转换为Datetime对象

我在以下位置找到此代码:

另外,请确保utcTime变量被强制转换为整数,因为Datetime.addSeconds()需要整数

utcTime = 1376986594;
createdDate = Datetime.newInstanceGmt(1970, 1, 1, 0, 0, 0);
createdDate.addSeconds(utcTime);
System.debug('DateTime: ' + createdDate);

谢谢你的建议。我尝试过使用integar.valueOf,但没有帮助!!