package routines; import java.text.SimpleDateFormat; import java.util.Date; /* * getDateFromEpoch: return yyyyMMdd from timestamp epoch * * * {talendTypes} Long * * {Category} User Defined * * {param} Long(Long) input: The timestamp to convert * * {example} getDateFromEpoch(epoch) */ public class JavaDateEpoch { /** * get part of date. like YEAR, MONTH, HOUR, or DAY_OF_WEEK, WEEK_OF_MONTH, WEEK_OF_YEAR, TIMEZONE and so on * * @param partName which part to get. * @param date the date value. * @return the specified part value. * * {talendTypes} Long * * {Category} User Defined * * {param} Long(Long) input: The timestamp to convert * * {example} getDateFromEpoch(epoch) * */ public static Long getDateFromEpoch(Long timeAsLong){ Long returnVal = null; if(timeAsLong!=null){ SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd"); String v = sdf.format(new Date(timeAsLong)); returnVal = Long.parseLong(v); } return returnVal; } }