Forums Register Login

What is the DateFormat.MEDIUM format's format?

+Pie Number of slices to send: Send
Ok, I know that I could do something like this:


and from the output, I can deduce what the DateFormat.MEDIUM format is.

What I'd like to do though, is just list what the format is, for each of my supported locales. I want output as follows:

en_CA = d-MMM-yyyy

Is this possible somehow?
+Pie Number of slices to send: Send
Use the SimpleDateFormat implementation of DateFormat and then call its toPattern or toLocalizedPattern method.
+Pie Number of slices to send: Send
Thanks Joanne, this is what I came up with :


It produces:
+Pie Number of slices to send: Send
Great - note that DateFormat.getDateInstance is only specified to return a DateFormat object, so any class that extends DateFormat could be returned
i.e. this is not guaranteed to work in every JRE - you could get a ClassCastException in some versions from this line
CAUTION! Do not touch the blades on your neck propeller while they are active. Tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 13638 times.
Similar Threads
how to split date and time?
Strange behavior of java.text.DateFormat
Wrong Hour/Timezone
A kinder, gentler java.util.Date?
DateFormat class - not getting result
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 18:08:40.