You first have to understand the rules you want to apply. What are your requirements ? Is it as simple as "replace 6 characters from the 6th position of the string" ? Or is it something more complicated ? Do you need to do it in Java, or, if you are using a database, can you do it straight from your SQL ?