package com.changhong.epc.count.service.system.func.set.date; import com.changhong.epc.count.service.system.func.set.AbsFuncSupper; import com.changhong.epc.count.service.tool.SystemFunTool; import com.googlecode.aviator.runtime.type.AviatorObject; import com.googlecode.aviator.runtime.type.AviatorString; import com.iemsoft.framework.cloud.core.tools.DateTool; import com.iemsoft.framework.cloud.core.tools.ObjectUtil; import lombok.extern.slf4j.Slf4j; import java.util.Date; import java.util.Map; /** * 日期加小时 返回日期 */ @Slf4j public class GetDateAddHour extends AbsFuncSupper { @Override public AviatorObject call(Map env, AviatorObject arg1,AviatorObject arg2) { if(ObjectUtil.empty(arg2.getValue(env))){ return fun_empty; } try{ String date = SystemFunTool.getStringVal(arg1, env); Double res = SystemFunTool.getNumberVal(arg2, env).doubleValue(); log.debug("GetDateAddHour.call('{}', '{}')", date, res); return new AviatorString( DateTool.dateToString( new Date(DateTool.stringToDate(date).getTime() + new Double(res*60*60*1000.0).longValue()) , DateTool.DATE_TO_STRING_DETAIAL_PATTERN )); }catch(Exception e){ return fun_empty; } } @Override public String getName() { // TODO Auto-generated method stub return FUNC_DATE_DATEADDHOUR; } }