commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Janek Bogucki <jane...@yahoo.co.uk>
Subject StringUtils.rightPad and StringUtils.leftPad fail to pad correctly
Date Sun, 16 Dec 2001 01:14:49 GMT
(I tried reporting this via the Apache Bug Database
but sandbox code isn't listed as a Commons component
so I hope this eventually finds the right person...)
-janek

StringUtils.rightPad and StringUtils.leftPad fail to
pad correctly with certain
categories of input. Some samples follow.


rightPad ( "1234", 8, "-+" ) = "1234" (Expected:
"1234-+-+")
rightPad ( "123456", 9, "-+~" ) = "123456" (Expected:
"123456-+~" )
leftPad ( "1234", 8, "-+" ) = "1234" (Expected:
"-+-+1234")
leftPad ( "123456", 9, "-+~" ) = "123456" (Expected:
"-+~123456" )

For convenience, some code to recreate these results:

        System.out.println ("rightPad ( 1234, 8, -+ )
= " +
        StringUtils.rightPad ( "1234", 8, "-+" )
        );
        
        System.out.println ("rightPad ( 123456, 9, -+~
) = " +
        StringUtils.rightPad ( "123456", 9, "-+~" )
        );
        
        System.out.println ("leftPad ( 1234, 8, -+ ) =
" +
        StringUtils.leftPad ( "1234", 8, "-+" )
        );
        
        System.out.println ("leftPad ( 123456, 9, -+~
) = " +
        StringUtils.leftPad ( "123456", 9, "-+~" )
        );

__________________________________________________
Do You Yahoo!?
Everything you'll ever need on one web page
from News and Sport to Email and Music Charts
http://uk.my.yahoo.com

--
To unsubscribe, e-mail:   <mailto:commons-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:commons-dev-help@jakarta.apache.org>


Mime
View raw message