String a = "{YY}-{MM}-{SEQNO}"; a = a.replace("YY", "17").replace("MM", "06").replace("SEQNO", "0001"); System.out.println(a); //Output: {17}-{06}-{0001}