java - Determine datetime pattern based on locale -
i have following jsf code display date using pattern.
<f:convertdatetime pattern="e, d mmm, yyyy" timezone="#{localebean.timez
one}" />
i pass pattern via localebean also. there way determine specific pattern based on locale?
thanks
public localebean() { this.defaulttimezone = timezone.getdefault(); this.strlocale = locale.getdefault().tostring(); this.timezone = defaulttimezone.getdisplayname(); }
you can try dateformat.getdateinstance
. example:
simpledateformat f = (simpledateformat)dateformat.getdateinstance(dateformat.short, locale.uk); system.out.println(f.topattern()); f = (simpledateformat)dateformat.getdateinstance(dateformat.short, locale.us); system.out.println(f.topattern());
prints:
dd/mm/yy m/d/yy
Comments
Post a Comment