You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Joe Black <pe...@hotmail.com> on 2007/12/26 03:45:43 UTC

myfaces 1.2.1 Date shifted 8 hours



 Hi,


I am using:-

myfaces-1.2.1-SNAPSHOT

Tomcat 6.0.14

Fedora Linux

java 1.6.0_02

tomahawk 1.1.6


I am extracting the data from my database and diplay on the page, which includes one Date field as follows:- 

 

<h:dataTable

 
value="#{hrHandler.allLeaveRecords}"

 
var="record"

 
columnClasses="columnOdd,columnEven"

binding="#{hrHandler.leaveRecordsDataTable}">

 

 

...

 

 
<h:column>

 
<f:facet name="header">

 
<h:commandLink

    id="dateFrom"

   
actionListener="#{hrHandler.sort}">

    <h:outputText
value="Date"/>

 
</h:commandLink>

 
</f:facet>

 
<h:outputText value="#{record.dateFrom}">

    <f:convertDateTime
pattern="dd-MMM-yyyy"/>

 
</h:outputText>

 
</h:column>

 

 
<h:column>

 
<f:facet name="header">

    <h:outputText
value="From"/>

 
</f:facet>

 
<h:outputText value="#{record.dateFrom}">

    <f:convertDateTime
pattern="HH:mm"/>

 
</h:outputText>

 
</h:column>

 

The time is earlier by 8 hours compared to the data extracted from the
database. It also happens that the my location is GMT+8. I am not sure whether
it is related to this.

However, if I use the JSF 1.2_07
Reference Implementation, it shows correctly.Can anybody guide me whether it is my configuration problem or the bug?


thanks and rgds,






 

 

 

 


_________________________________________________________________
Get your free suite of Windows Live services today!
http://www.get.live.com/wl/all

RE: myfaces 1.2.1 Date shifted 8 hours

Posted by "Jesse Alexander (KSFH 323)" <al...@credit-suisse.com>.
Hi
 
the date/time-shift depends also on the hosting JVM and the server-os...
Plus it might be possible that Sun already fixed something in that
area... I found the problem
there last summer.
What I would like to have is a config-option for a standard-timeZone for
the converter...
 
regards
Alexander


________________________________

	From: Joe Black [mailto:pelican5699@hotmail.com] 
	Sent: Saturday, December 29, 2007 4:57 AM
	To: MyFaces Discussion
	Subject: RE: myfaces 1.2.1 Date shifted 8 hours
	
	
	Hi,
	
	Thanks a lot. I followed your suggestion and add the timeZone
parameter and now it shows correctly using myfaces 1.2.1_07.
	
	However, just for your information, I am using the same code in
another parallel program using JSF RI and it shows the correct date
without adding timeZone parameter.
	
	Anyway, thanks a lot for pointing me in the correct direction.
	
	rgds,
	
	
	
	> Date: Fri, 28 Dec 2007 10:12:04 -0800
	> From: martin.ahrer@gmx.at
	> To: users@myfaces.apache.org
	> Subject: Re: myfaces 1.2.1 Date shifted 8 hours
	> 
	> 
	> See the FAQ at http://wiki.apache.org/myfaces/FAQ, SUN JSF RI
<1.2 has the
	> same issue as far as I know.
	> The f:convertDateTime tag supports a timezone attribut which
you can use to
	> set the timezone to be used by the converter!
	> 
	> Martin
	> 
	> 
	> -----
	> http://www.martinahrer.at/blog http://www.martinahrer.at/blog 
	> -- 
	> View this message in context:
http://www.nabble.com/myfaces-1.2.1-Date-shifted-8-hours-tp14499037p1452
9417.html
	> Sent from the MyFaces - Users mailing list archive at
Nabble.com.
	> 
	
	
________________________________

	Get your free suite of Windows Live services! Windows Live
<http://www.get.live.com/wl/all>  


RE: myfaces 1.2.1 Date shifted 8 hours

Posted by Joe Black <pe...@hotmail.com>.
Hi,

Thanks a lot. I followed your suggestion and add the timeZone parameter and now it shows correctly using myfaces 1.2.1_07.

However, just for your information, I am using the same code in another parallel program using JSF RI and it shows the correct date without adding timeZone parameter.

Anyway, thanks a lot for pointing me in the correct direction.

rgds,



> Date: Fri, 28 Dec 2007 10:12:04 -0800
> From: martin.ahrer@gmx.at
> To: users@myfaces.apache.org
> Subject: Re: myfaces 1.2.1 Date shifted 8 hours
> 
> 
> See the FAQ at http://wiki.apache.org/myfaces/FAQ, SUN JSF RI <1.2  has the
> same issue as far as I know.
> The f:convertDateTime tag supports a timezone attribut which you can use to
> set the timezone to be used by the converter!
> 
> Martin
> 
> 
> -----
> http://www.martinahrer.at/blog http://www.martinahrer.at/blog 
> -- 
> View this message in context: http://www.nabble.com/myfaces-1.2.1-Date-shifted-8-hours-tp14499037p14529417.html
> Sent from the MyFaces - Users mailing list archive at Nabble.com.
> 

_________________________________________________________________
Publish your photos to your Space easily with Photo Gallery.
http://www.get.live.com/wl/all

Re: myfaces 1.2.1 Date shifted 8 hours

Posted by Martin Ahrer <ma...@gmx.at>.
See the FAQ at http://wiki.apache.org/myfaces/FAQ, SUN JSF RI <1.2  has the
same issue as far as I know.
The f:convertDateTime tag supports a timezone attribut which you can use to
set the timezone to be used by the converter!

Martin


-----
http://www.martinahrer.at/blog http://www.martinahrer.at/blog 
-- 
View this message in context: http://www.nabble.com/myfaces-1.2.1-Date-shifted-8-hours-tp14499037p14529417.html
Sent from the MyFaces - Users mailing list archive at Nabble.com.


Re: myfaces 1.2.1 Date shifted 8 hours

Posted by simon <si...@chello.at>.
On Wed, 2007-12-26 at 10:45 +0800, Joe Black wrote:
>  Hi,
> 
> 
> I am using:-
> 
> myfaces-1.2.1-SNAPSHOT
> 
> Tomcat 6.0.14
> 
> Fedora Linux
> 
> java 1.6.0_02
> 
> tomahawk 1.1.6
> 
> 
> I am extracting the data from my database and diplay on the page,
> which includes one Date field as follows:- 
> 
>  
> 
> <h:dataTable
> 
>  value="#{hrHandler.allLeaveRecords}"
> 
>  var="record"
> 
>  columnClasses="columnOdd,columnEven"
> 
> binding="#{hrHandler.leaveRecordsDataTable}">
> 
>  
> 
>  
> 
> ...
> 
>  
> 
>  <h:column>
> 
>  <f:facet name="header">
> 
>  <h:commandLink
> 
>     id="dateFrom"
> 
>    actionListener="#{hrHandler.sort}">
> 
>     <h:outputText value="Date"/>
> 
>  </h:commandLink>
> 
>  </f:facet>
> 
>  <h:outputText value="#{record.dateFrom}">
> 
>     <f:convertDateTime pattern="dd-MMM-yyyy"/>
> 
>  </h:outputText>
> 
>  </h:column>
> 
>  
> 
>  <h:column>
> 
>  <f:facet name="header">
> 
>     <h:outputText value="From"/>
> 
>  </f:facet>
> 
>  <h:outputText value="#{record.dateFrom}">
> 
>     <f:convertDateTime pattern="HH:mm"/>
> 
>  </h:outputText>
> 
>  </h:column>
> 
>  
> 
> The time is earlier by 8 hours compared to the data extracted from the
> database. It also happens that the my location is GMT+8. I am not sure
> whether it is related to this.
> 
> However, if I use the JSF 1.2_07 Reference Implementation, it shows
> correctly.
> 
> Can anybody guide me whether it is my configuration problem or the
> bug?

Hmm..what you see (8 hours difference) is what I would expect, and I'm
surprised the Sun RI does what you report it does.

The JSF specification states quite clearly that the f:convertDateTime
will use UTC (ie GMT).  See the docs for method getTimeZone here:
http://java.sun.com/javaee/javaserverfaces/1.1_01/docs/api/javax/faces/convert/DateTimeConverter.html

A Date object is theoretically always in UTC (GMT).

The f:convertDateTime therefore accepts the Date object as being in GMT
already, and performs no adjustments as its default behaviour is to
render the Date in GMT (ie in the timezone it is already in). 

What I suspect is happening, therefore, is that when creating the Date
object from the database the correct timezone mapping is occurring -
your database date is in GMT+8, but the code is correctly causing this
to be moved backwards 8 hours to make the Date object contain the
equivalent value in the normalised GMT zone. But because you have not
specified a timezone on the f:convertDateTime component, it is
outputting this value as expected - in GMT.

The f:convertDateTime component has an optional timeZone attribute; I
suggest you try setting that to the timezone in which you want the value
to be interpreted.

The tomahawk sandbox has an s:convertDateTime component that uses the
timezone of the server on which the code is deployed as the default
timezone rather than GMT. This is good for small "intranet" apps, but
can be a bad thing for apps that are intended to support users in
multiple timezones.

Why the Sun RI would do what you expect I do not know...

Regards,

Simon