• 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

Date formatting

 
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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).

 
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
reply
    Bookmark Topic Watch Topic
  • New Topic