Java Service to convert Epoch Time to Simple Date Time Format

What is epoch time?

The Unix epoch (or Unix time or POSIX time or Unix timestamp) is the number of seconds that have elapsed since January 1, 1970 (midnight UTC/GMT), not counting leap seconds (in ISO 8601: 1970-01-01T00:00:00Z). Literally speaking the epoch is Unix time 0 (midnight 1/1/1970), but 'epoch' is often used as a synonym for Unix time. Some systems store epoch dates as a signed 32-bit integer, which might cause problems on January 19, 2038 (known as the Year 2038 problem or Y2038). The converter on this page converts timestamps in seconds (10-digit), milliseconds (13-digit) and microseconds (16-digit) to readable dates.

Human-readable time  Seconds
1 hour 3600 seconds
1 day 86400 seconds
1 week 604800 seconds
1 month (30.44 days)  2629743 seconds
1 year (365.24 days)   31556926 seconds

More details on https://www.epochconverter.com/

Here is the java utility service to convert Epoch Time to Simple Date Time Format. Create a java service "GetDateTimeByEpoch" and define the below input and output, copy-paste the code as provided below, add the required imports:

Input: epochTime (String)

Output: dateTimeStamp (String)

=================================================

import java.util.Locale; 
import java.text.SimpleDateFormat; 
import java.time.LocalDateTime; 
import java.time.ZoneOffset; 
import java.time.format.DateTimeFormatter; 
import java.util.Date; 

=================================================

IDataCursor pipelineCursor = pipeline.getCursor();

String epochTime = (String) IDataUtil.get(pipelineCursor, "epochTime");

//long unix_seconds = 1563370941;  

long unix_seconds = Long.parseLong(epochTime);

//convert seconds to milliseconds
  
Date date = new Date(unix_seconds * 1000 L);

// format of the date  

SimpleDateFormat jdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

String java_date = jdf.format(date);

//System.out.println("\n" + java_date + "\n");

IDataUtil.put(pipelineCursor, "dateTimeStamp", java_date);

pipelineCursor.destroy();
Note, if the input epochTime=1563370941000 (assuming that this timestamp is in milliseconds), then you might have to stripe the trailing zeros by dividing by 1000.