Hi please check this in my program String format = 19971230; i want to display this string like in the following format 1997-12-30 How can i add "-" after 4 characters and another "-" after 2 characters using if conditions... please help me.. this is urgent thanksinadvance yours rajesh
Matthew Margolis
Ranch Hand
Joined: Sep 29, 2001
Posts: 32
posted
0
you can just create a new string using the parts of that string seperated by a - read the first 4 then insert - then read two insert - read two insert -
Kaspar Dahlqvist
Ranch Hand
Joined: Jun 18, 2001
Posts: 128
posted
0
Tjipp! Maybe this can help you... StringBuffer sb = new StringBuffer("" + 20011119); sb.insert(4, '-'); sb.insert(7, '-'); System.out.println(sb.toString());