String trim() method
807580Oct 14 2009 — edited Oct 14 2009Hi all,
I use MS SQL Server and I have a table with the currency column of type: char(10). The currency is usually 3 chars like: USD; however looks like since the column type is of type: char(10), the database it adds up extra spaces at the end in order to make the length of Char to 10, so the "USD" becomes "USD ".
I use ResultSet.getString() method in order to read the column from ResultSet. In order to get rid of the extra spaces at the end, I use String.trim() method however, it looks like it does NOT get rid of extra spaces as expected or I should better say the behavior is random as sometimes the String I get after I used the trim() method is USD and other times is: USD .
Does anybody know why its happening?
Is there any other method I can use that gets rid of extra spaces?
Any help is greatly appreciated.