• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to format a string it title case???

 
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I see methods that help format string in to lower case and upper case but i could not see any function that does format to title case...how could I perform the same?
 
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry for the lack of knowledge, but what is 'title case' ?
 
Raghavan Chockalingam
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
for example: if you have a string like

java ranch is one of the best forums around

in title case it would be:
Java Ranch Is One Of The Best Forums Around
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You mean converting the initial to uppercase ?
I don't think there's such a method.
You'll have to get the first letter of each word and uppercase it.

Or you could use Jakarta's Common.lang library, and use StringUtils.capitalize(String str), or WordUtils.capitalize(String str) for converting a whole sentence.

See here for details.
[ January 03, 2006: Message edited by: Satou kurinosuke ]
 
Ranch Hand
Posts: 637
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Satou kurinosuke:
You mean converting the initial to uppercase ?
I don't think there's such a method.
You'll have to get the first letter of each word and uppercase it.

Or you could use Jakarta's Common.lang library, and use StringUtils.capitalize(String str), or WordUtils.capitalize(String str) for converting a whole sentence.

See here for details.

[ January 03, 2006: Message edited by: Satou kurinosuke ]




I recommend the latter. Commons Lang has all the methods you need.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic