This week's book giveaway is in the Design forum.
We're giving away four copies of Design for the Mind and have Victor S. Yocco on-line!
See this thread for details.
Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Date formatting

 
Aaron John
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I found the following code in the FAQs. I'd like to know how the date format can change depending on the locale, and without hardcoding the formatString, e.g. in the States, the general date format is MM-dd-yyyy (month first then date), while in the Australia the general date format is dd-MM-yyyy (date first then month).

 
Nicole Lacoste
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

You might want to try looking at the java.text.DateFormat
class. It has a method

Gets the date formatter with the given formatting style for the given locale.

Then you call format(Date) on the DateFormat object that this returns. You can use a DateFormat to read or write dates in a particular format. Have a look at the doc.
http://java.sun.com/j2se/1.4.2/docs/api/java/text/DateFormat.html

Niki
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic