@RestResource(urlMapping='/currentservertime')
global with sharing class SFA_GetCurrentServerDateTime {
//This is a wrapper class which will enclose the long response data string and return to external system
global class ResponseWrapper{
public String currentServerTime;
}
//@ Method Name: returnCurrentServerTime
//@ Description: This RESTful method returns the SFDC server timestamp to the calling program
//@ Arguments : none
//@ Returns : ResponseWrapper Object
@HttpGet
global static ResponseWrapper returnCurrentServerTime(){
dateTime newDate=system.now();
String dateInFormat = newDate.formatGMT('yyyy-MM-dd HH:mm:ss');
ResponseWrapper resWrap=new ResponseWrapper();
resWrap.currentServerTime=dateInFormat;
system.debug('Server time being sent:'+dateInFormat);
return resWrap;
}
}
Please find the above code .The standard REST API does not support this feature.Hence the above apex wrapper will generate the necesary API.
Please find the above code .The standard REST API does not support this feature.Hence the above apex wrapper will generate the necesary API.