Hi Nikita,
by default the locale of the request is taken, if your web-app support
this locale.
Have a look at your faces-config.xml
<application>
<locale-config>
<default-locale>en</default-locale>
<supported-locale>de</supported-locale>
<supported-locale>en</supported-locale>
<supported-locale>fr</supported-locale>
</locale-config>
</application>
If the locale couldn't determine for some reason or isn't supported, the
default locale is taken.
If don't want this behaviour, you can set the locale by using the
locale-attribute :
<f:convertDateTime locale="en" /> or through a backing bean
<f:convertDateTime locale="#{config.locale}" />
>[...]
>And also please help me in getting the current date according to the
>locale.
Setting the date according to locale is totally different task. That
means setting the correct timezone of the user.
In generally speaking the locale isn't associated with a timezone and so
you can't set the timezone according to a given locale. There are
several locales with different timezone. Imaging big countries like
russia. Thats the reason why the timezone isn't carried within the
request-header, but the locale is.
As a workaround for this i putted some javascript code to my pages, to
determine the timezone on the client-side. And saved the result to a
cookie, which i can access through server-side implementation.
If you determined the timezone you can set the timezone through the
timezone-attribute.
<f:convertDateTime timeZone="GMT"/>
I think the following javascript code works for gecko-based browsers :
<code>
// determining the clientside timezone
var d = new Date();
var iMinutes = d.getTimezoneOffset();
var timeStr = d.toLocaleString();
var timeZoneID = timeStr.substr(timeStr.length-3,3);
document.cookie = "clientTimezoneOffset=" + iMinutes;
document.cookie = "timeZoneID="+timeZoneID;
</code>
regards
Ronald
Nikita Shah wrote:
Hi
Am having a problem in displaying the date of curent locale in jsf tags.
I think by default the locale EN_US is taken. But i want it to be
currentLocale.
Please guide me if I am wrong. And also please help me in getting the
current date according to the locale.
The following is jsp page where i want to display the date in table.
<t:dataTable id="targetActualTable" border="1"
styleClass="sortable"
headerClass="targetActualTable_Header"
rowClasses="targetActualTable_Row1"
& nbsp; columnClasses="targetActualTable_Column"
var="target"
value="#{data.ta}"
cellpadding="0"
cellspacing="0"
align="center" >
<t:column>
<f:facet name="header">
<h:outputText value="Date" />
</f:facet>
<h:outputText value="#{target.date}" >
<f:convertDateTime type="date" pattern="MM/dd/yyyy " />
</h:outputText>
</t:column>
</t:dataTable>
Would appreciate any help.
TIA
Nikita
------------------------------------------------------------------------
Yahoo! Autos <http://us.rd.yahoo.com/evt=38381/
ylc=X3oDMTEzcGlrdGY5BF9TAzk3MTA3MDc2BHNlYwNtYWlsdGFncwRzbGsDMWF1dG9z/*http://autos.yahoo.com/index.html
>. Looking for a sweet ride? Get pricing, reviews, & more on new and
used cars.