aspose file tools*
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
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Urgent Please" Watch "Urgent Please" New topic
Author

Urgent Please

Rajesh Kumar
Greenhorn

Joined: Nov 16, 2001
Posts: 28
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
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
Tjipp!
Maybe this can help you...
StringBuffer sb = new StringBuffer("" + 20011119);
sb.insert(4, '-');
sb.insert(7, '-');
System.out.println(sb.toString());

//Kaspar
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Urgent Please