Getting pattern string from java SimpleDateFormat

DLaw picture DLaw · May 3, 2010 · Viewed 25.6k times · Source

I have a SimpleDateFormat object that I retrieve from some internationalization utilities. Parsing dates is all fine and good, but I would like to be able show a formatting hint to my users like "MM/dd/yyyy". Is there a way to get the formatting pattern from a SimpleDateFormat object?

Answer

skaffman picture skaffman · May 3, 2010

SimpleDateFormat.toPattern()

Returns a pattern string describing this date format.