I am trying to convert a GMT time which is stored as epoch into CST.
Below is the current code I am running in java.
if (originalRFC.get("sysmodtime")!=null){
var sysmod = originalRFC.get("sysmodtime"); // Hold the sysmodtime value in a variable
logger.debug('Sysmodtime Before: ' + sysmod); // Output to log before before converstion to CST - (in GMT)
var format = new java.text.SimpleDateFormat("MMMM d, yyyy HH:mm:ss a z"); // Format the string will be in
var dateString = sysmod.toLocaleString(); // Convert the epoch to the string equivalent in CST
var parsedDate = format.parse(dateString); // Convert that CST String back to epoch
var sysmodConvert = parsedDate.getTime(); // Convert it to time and milliseconds
logger.debug('Sysmodtime After: ' + sysmodConvert); //Output to log after conversion to CST
genericRFC.setField("last-update-time",sysmodConvert);
}
See the below errors that are returned in the log, we can see the time before"1301382996000", and it breaks when I try to convert:
2011-05-02 14:25:49,926 [http-8080-1] sm702-adapter_convert script - Sysmodtime Before: 1301382996000 2011-05-02 14:25:49,941 [http-8080-1] sm702-adapter_convert script - Error while calling function convert org.apache.bsf.BSFException: JavaScript Error: java.text.ParseException: Unparseable date: "[object JavaObject]"