The usual methods used for getting the pattern in Joda for Short Date-Time by passing locale is like below:
String pattern = DateTimeFormat.patternForStyle("SS", formatLocale);
But still is there any possibility for get the pattern(eg: yy-dd-mm H:mm) from a DateTimeformatter?
DateTimeFormatter format;
Can i get/retrieve pattern from this format object once all the details(locale, zone, country) are set?
If you look for a generic way to retrieve the format pattern for any arbitrarily constructed formatter, then the answer is: No, not possible.
Reason is that a formatter constructed via the builder pattern allows format details which cannot be covered by any pattern. Examples:
For the builder method appendYearOfCentury(...) there is no pattern equivalent. Or the formatter exploits the option to include a custom parser which can never be covered by any pattern symbol. Similar considerations are valid for other time libraries including Java-8, too.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With