public int compare( Object data1, Object data2 ) throws KettleValueException {
    Timestamp timestamp1 = getTimestamp( data1 );
    Timestamp timestamp2 = getTimestamp( data2 );
    int cmp = 0;
    if ( timestamp1 == null ) {
      if ( timestamp2 == null ) {
        cmp = 0;
      } else {
        cmp = -1;
      }
    } else if ( timestamp2 == null ) {
      cmp = 1;
    } else {
      cmp = timestamp1.compareTo( timestamp2 );
    }
    if ( isSortedDescending() ) {
      return -cmp;
    } else {
      return cmp;
    }
  }
@Test
  public void testCompare() throws Exception {
    ValueMetaTimestamp vm = new ValueMetaTimestamp();
    Timestamp earlier = Timestamp.valueOf( "2012-12-12 12:12:12.121212" );
    Timestamp later = Timestamp.valueOf( "2013-12-12 12:12:12.121212" );
    assertTrue( vm.isSortedAscending() );
    assertFalse( vm.isSortedDescending() );
    assertEquals( 0, vm.compare( null, null ) );
    assertEquals( -1, vm.compare( null, earlier ) );
    assertEquals( 1, vm.compare( earlier, null ) );
    assertEquals( 0, vm.compare( earlier, earlier ) );
    assertEquals( -1, vm.compare( earlier, later ) );
    assertEquals( 1, vm.compare( later, earlier ) );

    // Check Descending comparison
    vm.setSortedDescending( true );
    assertFalse( vm.isSortedAscending() );
    assertTrue( vm.isSortedDescending() );
    assertEquals( 0, vm.compare( null, null ) );
    assertEquals( 1, vm.compare( null, earlier ) );
    assertEquals( -1, vm.compare( earlier, null ) );
    assertEquals( 0, vm.compare( earlier, earlier ) );
    assertEquals( 1, vm.compare( earlier, later ) );
    assertEquals( -1, vm.compare( later, earlier ) );
  }