Meaningless Drivel is fun!*
The moose likes Java in General and the fly likes Date formatting Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Date formatting" Watch "Date formatting" New topic
Author

Date formatting

Aaron John
Ranch Hand

Joined: May 30, 2005
Posts: 74
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

Joined: Oct 04, 2006
Posts: 30
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Date formatting