@Test public void createDateObjectTest() throws KettleValueException, ParseException { SalesforceStep step = spy( new MockSalesforceStep( smh.stepMeta, smh.stepDataInterface, 0, smh.transMeta, smh.trans ) ); ValueMetaInterface valueMeta = Mockito.mock( ValueMetaInterface.class ); DateFormat dateFormat = new SimpleDateFormat( "dd-MM-yyyy hh:mm:ss" ); Date date = dateFormat.parse( "12-10-2017 15:10:25" ); Mockito.when( valueMeta.isDate() ).thenReturn( true ); Mockito.when( valueMeta.getDateFormatTimeZone() ).thenReturn( TimeZone.getTimeZone( "UTC" ) ); Mockito.when( valueMeta.getDate( Mockito.eq( date ) ) ).thenReturn( date ); Object value = step.normalizeValue( valueMeta, date ); Assert.assertTrue( value instanceof Calendar ); DateFormat minutesDateFormat = new SimpleDateFormat( "mm:ss" ); Assert.assertEquals( minutesDateFormat.format( date ), minutesDateFormat.format( ( (Calendar) value ).getTime() ) ); }
public Object normalizeValue( ValueMetaInterface valueMeta, Object value ) throws KettleValueException { if ( valueMeta.isDate() ) { Calendar cal = Calendar.getInstance( valueMeta.getDateFormatTimeZone() ); cal.setTime( valueMeta.getDate( value ) ); Calendar utc = Calendar.getInstance( TimeZone.getTimeZone( "UTC" ) ); utc.clear(); utc.set( cal.get( Calendar.YEAR ), cal.get( Calendar.MONTH ), cal.get( Calendar.DATE ), cal.get( Calendar.HOUR_OF_DAY ), cal.get( Calendar.MINUTE ), cal.get( Calendar.SECOND ) ); value = utc; } else if ( valueMeta.isStorageBinaryString() ) { value = valueMeta.convertToNormalStorageType( value ); } if ( ValueMetaInterface.TYPE_INTEGER == valueMeta.getType() ) { value = Ints.checkedCast( (Long) value ); } return value; }
SalesforceStep extends BaseStep implements StepInterface { public Object normalizeValue( ValueMetaInterface valueMeta, Object value ) throws KettleValueException { if ( valueMeta.isDate() ) { Calendar cal = Calendar.getInstance( valueMeta.getDateFormatTimeZone() ); cal.setTime( valueMeta.getDate( value ) ); Calendar utc = Calendar.getInstance( TimeZone.getTimeZone( "UTC" ) ); utc.clear(); utc.set( cal.get( Calendar.YEAR ), cal.get( Calendar.MONTH ), cal.get( Calendar.DATE ), cal.get( Calendar.HOUR_OF_DAY ), cal.get( Calendar.MINUTE ), cal.get( Calendar.SECOND ) ); value = utc; } else if ( valueMeta.isStorageBinaryString() ) { value = valueMeta.convertToNormalStorageType( value ); } if ( ValueMetaInterface.TYPE_INTEGER == valueMeta.getType() ) { value = Ints.checkedCast( (Long) value ); } return value; } }
SalesforceStep extends BaseStep implements StepInterface { public Object normalizeValue( ValueMetaInterface valueMeta, Object value ) throws KettleValueException { if ( valueMeta.isDate() ) { Calendar cal = Calendar.getInstance( valueMeta.getDateFormatTimeZone() ); cal.setTime( valueMeta.getDate( value ) ); Calendar utc = Calendar.getInstance( TimeZone.getTimeZone( "UTC" ) ); utc.clear(); utc.set( cal.get( Calendar.YEAR ), cal.get( Calendar.MONTH ), cal.get( Calendar.DATE ), cal.get( Calendar.HOUR_OF_DAY ), cal.get( Calendar.MINUTE ), cal.get( Calendar.SECOND ) ); value = utc; } else if ( valueMeta.isStorageBinaryString() ) { value = valueMeta.convertToNormalStorageType( value ); } if ( ValueMetaInterface.TYPE_INTEGER == valueMeta.getType() ) { value = Ints.checkedCast( (Long) value ); } return value; } SalesforceStep( StepMeta stepMeta, StepDataInterface stepDataInterface, int copyNr, TransMeta transMeta,
      Trans trans ); }
SalesforceStep extends BaseStep implements StepInterface { public Object normalizeValue( ValueMetaInterface valueMeta, Object value ) throws KettleValueException { if ( valueMeta.isDate() ) { Calendar cal = Calendar.getInstance( valueMeta.getDateFormatTimeZone() ); cal.setTime( valueMeta.getDate( value ) ); Calendar utc = Calendar.getInstance( TimeZone.getTimeZone( "UTC" ) ); utc.clear(); utc.set( cal.get( Calendar.YEAR ), cal.get( Calendar.MONTH ), cal.get( Calendar.DATE ), cal.get( Calendar.HOUR_OF_DAY ), cal.get( Calendar.MINUTE ), cal.get( Calendar.SECOND ) ); value = utc; } else if ( valueMeta.isStorageBinaryString() ) { value = valueMeta.convertToNormalStorageType( value ); } if ( ValueMetaInterface.TYPE_INTEGER == valueMeta.getType() ) { value = Ints.checkedCast( (Long) value ); } return value; } SalesforceStep( StepMeta stepMeta, StepDataInterface stepDataInterface, int copyNr, TransMeta transMeta,
      Trans trans ); @Override boolean init( StepMetaInterface smi, StepDataInterface sdi ); void dispose( StepMetaInterface smi, StepDataInterface sdi ); Object normalizeValue( ValueMetaInterface valueMeta, Object value ); }
SalesforceStep extends BaseStep implements StepInterface { public Object normalizeValue( ValueMetaInterface valueMeta, Object value ) throws KettleValueException { if ( valueMeta.isDate() ) { Calendar cal = Calendar.getInstance( valueMeta.getDateFormatTimeZone() ); cal.setTime( valueMeta.getDate( value ) ); Calendar utc = Calendar.getInstance( TimeZone.getTimeZone( "UTC" ) ); utc.clear(); utc.set( cal.get( Calendar.YEAR ), cal.get( Calendar.MONTH ), cal.get( Calendar.DATE ), cal.get( Calendar.HOUR_OF_DAY ), cal.get( Calendar.MINUTE ), cal.get( Calendar.SECOND ) ); value = utc; } else if ( valueMeta.isStorageBinaryString() ) { value = valueMeta.convertToNormalStorageType( value ); } if ( ValueMetaInterface.TYPE_INTEGER == valueMeta.getType() ) { value = Ints.checkedCast( (Long) value ); } return value; } SalesforceStep( StepMeta stepMeta, StepDataInterface stepDataInterface, int copyNr, TransMeta transMeta,
      Trans trans ); @Override boolean init( StepMetaInterface smi, StepDataInterface sdi ); void dispose( StepMetaInterface smi, StepDataInterface sdi ); Object normalizeValue( ValueMetaInterface valueMeta, Object value ); static Class<?> PKG; public SalesforceStepMeta meta; public SalesforceStepData data; }