You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Nikita Shah <ni...@yahoo.com> on 2006/01/20 08:02:32 UTC

Problem in displaying dates(Locale)

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" 
                            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. Looking for a sweet ride? Get pricing, reviews, & more on new and used cars.

Re: Problem in displaying dates(Locale)

Posted by Nikita Shah <ni...@yahoo.com>.
Hi Adrien
  
  Thanks a lot for your reply, I did follow that link and got a workaround for it too...
  
  ~Nikita

Adrien FOURES <af...@sigems.fr> wrote:  Look MYFACES-656  in 
myfaces' bug database (jira)




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 i n getting the 
> current date according to the locale.
> The following is jsp page where i want to display the date in table.
>
> 
>             &nbs p;           styleClass="sortable"
>                         headerClass="targetActualTable_Header"
>    ;                      rowClasses="targetActualTable_Row1"
>                  & nbsp;      columnClasses="targetActualTable_Column"
>                         var="target"
>          &n bsp;              value="#{data.ta}"
>                         cellpadding="0"
>       ;                   cellspacing="0"
>                         align="center" >             
>             
>                 
>                     
>               ;   
>                 
>                 
>                 
>             
> 
>
> Would appreciate any help.
>
> TIA
> Nikita
>
> ------------------------------------------------------------------------
> Yahoo! Autos 
> . 
> Looking for a sweet ride? Get pricing, reviews, & more on new and used 
> c ars.
>
>------------------------------------------------------------------------
>
>No virus found in this incoming message.
>Checked by AVG Free Edition.
>Version: 7.1.375 / Virus Database: 267.14.21/235 - Release Date: 19/01/2006
>
>  
>



		
---------------------------------
 Yahoo! Autos. Looking for a sweet ride? Get pricing, reviews, & more on new and used cars.

Re: Problem in displaying dates(Locale)

Posted by Adrien FOURES <af...@sigems.fr>.
Look MYFACES-656 <http://issues.apache.org/jira/browse/MYFACES-656> in 
myfaces' bug database (jira)




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 i n 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"
>             &nbs p;           styleClass="sortable"
>                         headerClass="targetActualTable_Header"
>    ;                      rowClasses="targetActualTable_Row1"
>                  & nbsp;      columnClasses="targetActualTable_Column"
>                         var="target"
>          &n bsp;              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:convertD ateTime type="date" pattern="MM/dd/yyyy " />
>                 </h:outputText>
>             </t:column>
> </t:dataTable& gt;
>
> Would appreciate any help.
>
> TIA
> Nikita
>
> ------------------------------------------------------------------------
> Yahoo! Autos 
> <http://us.rd.yahoo.com/evt=38381/%20ylc=X3oDMTEzcGlrdGY5BF9TAzk3MTA3MDc2BHNlYwNtYWlsdGFncwRzbGsDMWF1dG9z/*http://autos.yahoo.com/index.html%20>. 
> Looking for a sweet ride? Get pricing, reviews, & more on new and used 
> c ars.
>
>------------------------------------------------------------------------
>
>No virus found in this incoming message.
>Checked by AVG Free Edition.
>Version: 7.1.375 / Virus Database: 267.14.21/235 - Release Date: 19/01/2006
>
>  
>

Re: Problem in displaying dates(Locale)

Posted by "R. Müller" <r....@unicomp-berlin.de>.
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.