This week's book giveaway is in the JDBC forum.
We're giving away four copies of Make it so: Java DB Connections & Transactions and have Marcho Behler on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Urgent Please Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Make it so: Java DB Connections & Transactions this week in the JDBC forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Urgent Please" Watch "Urgent Please" New topic

Urgent Please

Rajesh Kumar

Joined: Nov 16, 2001
Posts: 28
please check this
in my program
String format = 19971230;
i want to display this string like in the following format
How can i add "-" after 4 characters and another "-" after 2 characters using if conditions...
please help me..
this is urgent
Matthew Margolis
Ranch Hand

Joined: Sep 29, 2001
Posts: 32
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
Maybe this can help you...
StringBuffer sb = new StringBuffer("" + 20011119);
sb.insert(4, '-');
sb.insert(7, '-');

I agree. Here's the link:
subject: Urgent Please
It's not a secret anymore!