Salesforce Apex中的字符串格式
我必须将字符串day='11/22/1999'格式化为'2020-11-26T00:00:00-05:00',此字符串格式在apex中的默认时间值为0。请告诉我是否有人对此进行了操作。这将在运行用户的时区中输出。Salesforce Apex中的字符串格式,salesforce,apex-code,Salesforce,Apex Code,我必须将字符串day='11/22/1999'格式化为'2020-11-26T00:00:00-05:00',此字符串格式在apex中的默认时间值为0。请告诉我是否有人对此进行了操作。这将在运行用户的时区中输出。 System.debug(formatDate('11/22/1999')); //1999-11-22T00:00:00-05:00 String formatDate(String dateString) { Date d = Date.parse(dateString)
System.debug(formatDate('11/22/1999')); //1999-11-22T00:00:00-05:00
String formatDate(String dateString) {
Date d = Date.parse(dateString);
Datetime dt = Datetime.newInstance(d.year(), d.month(), d.day(), 0, 0, 0);
return dt.format('yyyy-MM-dd\'T\'HH:mm:ssXXX');
}
欢迎来到堆栈溢出。到目前为止,你的解决方案是什么。什么不适合你?不要期望这样做会为你做的工作。要改进您的问题,请阅读、和。