0 votes
216 views
in Programming by (1.4k points)
Hello guys I am trying to get localized data pattern string, Here I know about how to format dates, some how I need pattern.
See my code I have format current date into short localize date: 
 
DateFormat formatter = DateFormat.getDateInstance(DateFormat.SHORT, Locale.getDefault());
String today = formatter.format(new Date());
Now I want to obtain the localize pattern string in some format lets say format is "mm/dd/yy" , I hope you got my question. Thanks For your answer!

 

1 Answer

0 votes
by Expert (3.8k points)
 In Java 8 there is DateTimeFormatterBuilder you can use it like this:
 
  String dateDemo = DateTimeFormatterBuilder.getLocalizedDateTimePattern
  (FormatStyle.SHORT, null, IsoChronology.INSTANCE, Locale.GERMANY); 
  
  Another option is that you can use toLocalizedPattern()  for SimpleDateFormat .
  For info of toLocalizedPattern()
  
  I hope it may help you out.

Not a Member yet?

Ask to Folks Login

My Account

Your feedback is highly appreciated