kettle java组件 时间戳
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
public boolean processRow(StepMetaInterface smi, StepDataInterface sdi) throws KettleException
{Object[] r=getRow();
if(r==null){setOutputDone();
return false;}
if(first){
try{ first=false;
String var1=get(Fields.In,"JLRKSJ").getString(r);
SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date date=sdf.parse(var1);
getTrans().getParentJob().setVariable("max_stamp",String.valueOf(date.getTime()));
}catch(Exception e){
throw new KettleException("convert time error!",e);
}
}putRow(data.outputRowMeta,r);
return true;
}
public boolean processRow(StepMetaInterface smi, StepDataInterface sdi) throws KettleException
{
if (first){
first = false;
/* TODO: Your code here. (Using info fields)
FieldHelper infoField = get(Fields.Info, "info_field_name");
RowSet infoStream = findInfoRowSet("info_stream_tag");
Object[] infoRow = null;
int infoRowCount = 0;
// Read all rows from info step before calling getRow() method, which returns first row from any
// input rowset. As rowMeta for info and input steps varies getRow() can lead to errors.
while((infoRow = getRowFrom(infoStream)) != null){
// do something with info data
infoRowCount++;
}
*/
}
Object[] r = getRow();
if (r == null) {
setOutputDone();
return false;
}
// It is always safest to call createOutputRow() to ensure that your output row's Object[] is large
// enough to handle any new fields you are creating in this step.
r = createOutputRow(r, data.outputRowMeta.size());
/* TODO: Your code here. (See Sample)
// Get the value from an input field
String foobar = get(Fields.In, "a_fieldname").getString(r);
foobar += "bar";
// Set a value in a new output field
get(Fields.Out, "output_fieldname").setValue(r, foobar);
*/
// Send the row on to the next step.
putRow(data.outputRowMeta, r);
return true;
}