How can I create a SHORT-style DateFormat with a four digit year that works for all locales?

One method involves modifying the existing pattern from "yy" to "yyyy". The DateFormat factory methods generally return a SimpleDateFormat. Use SimpleDateFormat's toPattern() to retrieve the pattern String, insert the additional "yy" and then use applyPattern() with the modified pattern. Note that the documentation states "you can try casting the DateFormat you get from the factory methods to a SimpleDateFormat. This will work for the majority of countries; just remember to put it in a try block in case you encounter an unusual one." You can also use instanceof, which is the case in the following code sample.

Advertiser Disclosure:
Some of the products that appear on this site are from companies from which QuinStreet receives compensation. This compensation may impact how and where products appear on this site including, for example, the order in which they appear. QuinStreet does not include all companies or all types of products available in the marketplace.