• 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
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

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
 
The world's cheapest jedi mind trick: "Aw c'mon, why not read this tiny ad?"
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic