@Test public void testFormat() throws Exception { 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( "KETTLE" ); checkFormat( "DB.DEFAULT" ); checkFormat( "LOCALE.DEFAULT" ); } }
@Override public StringBuffer format( Date timestamp, StringBuffer toAppendTo, FieldPosition pos ) { if ( compatibleToSuperPattern ) { return super.format( timestamp, toAppendTo, pos ); } 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 ); }
SimpleTimestampFormat extends SimpleDateFormat { @Override public StringBuffer format( Date timestamp, StringBuffer toAppendTo, FieldPosition pos ) { if ( compatibleToSuperPattern ) { return super.format( timestamp, toAppendTo, pos ); } 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 ); } }
SimpleTimestampFormat extends SimpleDateFormat { @Override public StringBuffer format( Date timestamp, StringBuffer toAppendTo, FieldPosition pos ) { if ( compatibleToSuperPattern ) { return super.format( timestamp, toAppendTo, pos ); } 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 ); } SimpleTimestampFormat( String pattern );  SimpleTimestampFormat( String pattern, Locale locale );  SimpleTimestampFormat( String pattern, DateFormatSymbols formatSymbols ); }
SimpleTimestampFormat extends SimpleDateFormat { @Override public StringBuffer format( Date timestamp, StringBuffer toAppendTo, FieldPosition pos ) { if ( compatibleToSuperPattern ) { return super.format( timestamp, toAppendTo, pos ); } 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 ); } SimpleTimestampFormat( String pattern );  SimpleTimestampFormat( String pattern, Locale locale );  SimpleTimestampFormat( String pattern, DateFormatSymbols formatSymbols ); @Override void setDateFormatSymbols( DateFormatSymbols newFormatSymbols ); @Override StringBuffer format( Date timestamp, StringBuffer toAppendTo, FieldPosition pos ); @Override AttributedCharacterIterator formatToCharacterIterator( Object obj ); @Override Date parse( String text, ParsePosition pos ); @Override String toPattern(); @Override String toLocalizedPattern(); @Override void applyPattern( String pattern ); @Override void applyLocalizedPattern( String pattern ); @Override Date parse( String source ); @Override Object parseObject( String source, ParsePosition pos ); }
SimpleTimestampFormat extends SimpleDateFormat { @Override public StringBuffer format( Date timestamp, StringBuffer toAppendTo, FieldPosition pos ) { if ( compatibleToSuperPattern ) { return super.format( timestamp, toAppendTo, pos ); } 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 ); } SimpleTimestampFormat( String pattern );  SimpleTimestampFormat( String pattern, Locale locale );  SimpleTimestampFormat( String pattern, DateFormatSymbols formatSymbols ); @Override void setDateFormatSymbols( DateFormatSymbols newFormatSymbols ); @Override StringBuffer format( Date timestamp, StringBuffer toAppendTo, FieldPosition pos ); @Override AttributedCharacterIterator formatToCharacterIterator( Object obj ); @Override Date parse( String text, ParsePosition pos ); @Override String toPattern(); @Override String toLocalizedPattern(); @Override void applyPattern( String pattern ); @Override void applyLocalizedPattern( String pattern ); @Override Date parse( String source ); @Override Object parseObject( String source, ParsePosition pos ); static final String DEFAULT_TIMESTAMP_FORMAT; }