• 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:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Junilu Lacar
  • Liutauras Vilda
Sheriffs:
  • Paul Clapham
  • Jeanne Boyarsky
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
Bartenders:
  • Jesse Duncan
  • Frits Walraven
  • Mikalai Zaikin

convert day of week

 
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Now I have other ways of doing this but I was trying not to clutter up code. I am looking for an elegant way to do this. I have a string "MON", which I would to become "Monday". Is there some already written static routine in java that can do this. I have looked at the Calendar class a bit but this is not what it is designed for. I am thinking I will just have to write my own class. Well there probably is a way to get it out of Calendar but it's probably some formatting trick. Any ideas?

 
Sheriff
Posts: 22656
126
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Check out DateFormat and its subclass SimpleDateFormat. In essence, you do the following:
- create a (Simple)DateFormat that will only use the day of week
- use its parse method to create a Date
- use its format method to turn it back into the week day String
In short code:
You'll have to experiment a bit with repeating the day of the week pattern symbol; if you repeat it enough it will work the way you want.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic