### Question:
ValueMetaTimestamp extends ValueMetaDate { public int compare( Object data1, Object data2 ) throws HopValueException { 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; } } ValueMetaTimestamp();  ValueMetaTimestamp( String name ); @Override boolean isDate(); @Override Date getDate( Object object ); @Override Long getInteger( Object object ); @Override Double getNumber( Object object ); @Override BigDecimal getBigNumber( Object object ); @Override Boolean getBoolean( Object object ); @Override String getString( Object object ); Timestamp getTimestamp( Object object ); int compare( Object data1, Object data2 ); @Override Object convertDataFromString( String pol, IValueMeta convertMeta, String nullIf, String ifNull,
                                       int trim_type ); Timestamp convertDateToTimestamp( Date date ); @Override Object convertData( IValueMeta meta2, Object data2 ); @Override Object cloneValueData( Object object ); @Override IValueMeta getMetadataPreview( DatabaseMeta databaseMeta, ResultSet rs ); @Override IValueMeta getValueFromSqlType(DatabaseMeta databaseMeta, String name, ResultSetMetaData rm,
                                        int index, boolean ignoreLength, boolean lazyConversion ); @Override Object getValueFromResultSet( IDatabase iDatabase, ResultSet resultSet, int index ); @Override void setPreparedStatementValue( DatabaseMeta databaseMeta, PreparedStatement preparedStatement, int index,
                                         Object data ); @Override Object convertDataUsingConversionMetaData( Object data2 ); @Override byte[] getBinaryString( Object object ); @Override void writeData( DataOutputStream outputStream, Object object ); @Override Object readData( DataInputStream inputStream ); @Override synchronized SimpleDateFormat getDateFormat(); @Override String getFormatMask(); @Override Class<?> getNativeDataTypeClass();  }### Answer:
@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( vm.compare( null, null ), 0 ); assertEquals( vm.compare( null, earlier ), -1 ); assertEquals( vm.compare( earlier, null ), 1 ); assertEquals( vm.compare( earlier, earlier ), 0 ); assertEquals( vm.compare( earlier, later ), -1 ); assertEquals( vm.compare( later, earlier ), 1 ); vm.setSortedDescending( true ); assertFalse( vm.isSortedAscending() ); assertTrue( vm.isSortedDescending() ); assertEquals( vm.compare( null, null ), 0 ); assertEquals( vm.compare( null, earlier ), 1 ); assertEquals( vm.compare( earlier, null ), -1 ); assertEquals( vm.compare( earlier, earlier ), 0 ); assertEquals( vm.compare( earlier, later ), 1 ); assertEquals( vm.compare( later, earlier ), -1 ); }