Monday, April 05, 2010

Salesforce: Timezone, CreatedOn - trivial fix

I was showing list of records with createdDateTime. Created date was being shown in GMT at one place for same record
and it was shown in IST format at other place. I thought both places I am doing same thing but result was different.
It was all Salesforce's magic Apex languange rendering.

following code was showing date in GMT despite global setting being IST.
< apex:pageBlockTable value="{!recentList}" var="item" >
< apex:column >
< apex:facet name="header" >Created On< / apex:facet >
< apex:outputText value="{!item.CreatedDate}" />
< / apex:column >

< / apex:pageBlockTable>

Slight change in the code fixed this issue. removed facet and outputText.

< apex:pageBlockTable value="{!recentList}" var="item" >
< apex:column value="{!sms.CreatedDate}" headerValue="CreatedOn" / >

< / apex:pageBlockTable>

No comments: