@Override
  public StringBuffer format( Date timestamp, StringBuffer toAppendTo, FieldPosition pos ) {

    if ( compatibleToSuperPattern ) {
      return super.format( timestamp, toAppendTo, pos );
    }

    SimpleDateFormat defaultMillisecondDateFormat = new SimpleDateFormat( DEFAULT_MILLISECOND_DATE_FORMAT, Locale.US );

    StringBuffer dateBuffer;
    String nan;

    if ( timestamp instanceof Timestamp ) {
      Timestamp tmp = (Timestamp) timestamp;
      Date date = new Date( tmp.getTime() );
      dateBuffer = super.format( date, toAppendTo, pos );
      nan = formatNanoseconds( tmp.getNanos() );

    } else {
      dateBuffer = super.format( timestamp, toAppendTo, pos );
      String milliseconds = defaultMillisecondDateFormat.format( timestamp );
      nan = formatNanoseconds( Integer.valueOf( milliseconds ) * Math.pow( 10, 6 ) );
    }

    int placeholderPosition = replaceHolder( dateBuffer, false );
    return dateBuffer.insert( pos.getBeginIndex() + placeholderPosition, nan );
  }
@Test
  public void testFormat() {
    for ( Locale locale : locales ) {
      Locale.setDefault( Locale.Category.FORMAT, locale );
      tdb = ResourceBundle.getBundle( "org/pentaho/di/core/row/value/timestamp/messages/testdates", locale );
      checkFormat( "KETTLE.LONG" );
      checkFormat( "LOCALE.DATE", new SimpleTimestampFormat( new SimpleDateFormat().toPattern() ) );
      //checkFormat( "LOCALE.TIMESTAMP", new SimpleTimestampFormat( new SimpleDateFormat().toPattern() ) );
      checkFormat( "KETTLE" );
      checkFormat( "DB.DEFAULT" );
      checkFormat( "LOCALE.DEFAULT" );
    }
  }