I need to present a "mask" on a GUI screen representing a date in the current locale's short format, which may include a 4-digit year. How do I know which field is the year? I can get the localized pattern used by the DateFormat object, but the symbols seem to change based on the Locale!

Joe Sam Shirah

Use SimpleDateFormat.toPattern() to get the unlocalized pattern ( as opposed to toLocalizedPattern() ). The returned String uses the symbols referenced in the SimpleDateFormat documentation.

For an example of retrieving/changing this pattern, see How can I create a SHORT-style DateFormat with a four digit year that works for all locales?.

0 Comments  (click to add your comment)
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

About | Sitemap | Contact