Format date for a Locale
A very common use case related to localization is that, formatting the date specific to a user-selected locale.
Following code snippet will help you to identify the default pattern corresponding to a locale.
Your jsf page snippet may look like:
Following code snippet will help you to identify the default pattern corresponding to a locale.
String pattern =
((SimpleDateFormat)DateFormat.getDateTimeInstance(SimpleDateFormat.FULL,
SimpleDateFormat.LONG,
locale)).toPattern();
Your jsf page snippet may look like:
<af:inputDate label="Date:" id="id1" value="#{viewScope.TestBean.date}"
binding="#{viewScope.TestBean.inputDate}"
partialTriggers="soc1">
<af:convertDateTime type="both"
timeZone="#{viewScope.TestBean.timeZone}"
locale="#{viewScope.TestBean.locale}"
pattern="#{viewScope.TestBean.pattern}"
/>
</af:inputDate>
You can download the sample workspace from here.
Thanks this was helpful.
ReplyDeleteHi Jobinesh,
ReplyDeleteThanks for the Article.
Can we specify the pattern at global level.
I have figured it out that we can specify the timezone in trinidad-config to have effect on globally.
Any hints appreciated.
Thanks.