流程图
image.png-
获取时间
image.png -
Java代码
image.png
import java.text.ParseException;
import java.util.Date;
public boolean processRow(StepMetaInterface smi, StepDataInterface sdi) throws KettleException
{
Object[] r = getRow();
if (r == null)
{
setOutputDone();
return false;
}
if (first)
{
first = false;
}
String tmp_time = get(Fields.In,"date").getString(r);
Long time_stamp = dateToStamp(tmp_time);
r = createOutputRow(r, data.outputRowMeta.size());
get(Fields.Out, "_time_stamp").setValue(r,time_stamp);
putRow(data.outputRowMeta,r);
return true;
}
public static Long dateToStamp(String s)
{
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
Date date = new Date();
try
{
date = simpleDateFormat.parse(s);
}
catch (ParseException e)
{
}
Long ts = date.getTime();
return ts;
}
-
执行结果
image.png
网友评论