• Post Reply Bookmark Topic Watch Topic
  • New Topic

make space in a string  RSS feed

 
praneeth ram
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
jul02, 1986

hi all i want make a space between jul and 2.

expecting result: jul 02, 1986.

can any one please tell me the way.

Thanks,
Praneeth
 
Tom Reilly
Rancher
Posts: 618
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There are many ways to do this, depending on the complexity of your needs. Given only the requirements you detail, I would look at the StringBuilder.insert() method.
 
fred rosenberger
lowercase baba
Bartender
Posts: 12562
49
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here's one way to do it:



That may seem like a smart-alec answer, but i'm trying to illustrate a point. writing good code is all about understanding the subtle details of what the problem is. We don't know enough at this point to help.

Will you ever have dates in months other than july? If so, will they always be three characters? Will you only ever have the date 02? Will you sometimes get "Jul" instead of "jul"?

These are some of the questions you need to ask before you can really come up with a good solution.

If you're just looking for a quick hack, then my code above will do the trick.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!