Forum Stats

  • 3,757,668 Users
  • 2,251,254 Discussions
  • 7,869,883 Comments

Discussions

Jython code understand

Robeen
Robeen Member Posts: 2,085 Silver Badge

Hi,


I would like to get help understand this piece of jython code. This is used to convert date


from datetime import date,datetime,timedelta

for record in sdc.records: <<------ is sdc an object? From which class? Is records a variable?

 try:

  for (field,vals) in record.value.iteritems(): << is record an object? what is value/iteritems?

    sdc.log.info("{}",vals)

    sdc.log.info("{}",type(vals))

    if 'Date' in str(type(vals)):

     sdc.log.info("Converted: {}", date.fromtimestamp(vals.getTime()+14400 ))

     sdc.log.info("After: {}", date.fromtimestamp(vals.getTime()+14400 ))

     record[field] = date.fromtimestamp(vals.getTime()+14400 )

  sdc.output.write(record)


 except Exception as e:

  # Send record to error

  sdc.error.write(record, str(e))


Thanks,


Joe