0

Application: a digital clock. I want to know whether the current date should be displayed as mm.dd.yy or dd.mm.yy for the current locale. Bonus points for identifying yy.mm.dd cases. (I an perfectly content to not support non-Gregorian calendars).

So for example: Should January 31, 2019 be displayed as 01.31.19, or 31.01.19.

Being able to get a short date format string would suffice. i.e. "MM/dd/yy", or "yy.MM.dd".

I've rummaged through DateFormat, and SimpleDateFormat (the latter of which has what I need in the pattern private member, but doesn't provide public access). But as usual, date support in Java is infuriatingly... complicated. :-(

Robin Davies
  • 7,547
  • 1
  • 35
  • 50
  • 1
    Can you use the new `java.time` package instead? – Eng.Fouad Mar 11 '20 at 22:16
  • As an aside consider throwing away the long outmoded and notoriously troublesome `SimpleDateFormat` and friends, and adding [ThreeTenABP](https://github.com/JakeWharton/ThreeTenABP) to your Android project in order to use java.time, the modern Java date and time API. It is so much nicer to work with. – Ole V.V. Mar 12 '20 at 04:34

0 Answers0