function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Edwin VijayEdwin Vijay 

Date field does not display in VF

java.util.GregorianCalendar[time=1213779900000,areFieldsSet=true,areAllFieldsSet=true,lenient=true,zone=sun.util.calendar.ZoneInfo[id="GMT",offset=0,dstSavings=0,useDaylight=false,transitions=0,lastRule=null],firstDayOfWeek=1,minimalDaysInFirstWeek=1,ERA=1,YEAR=2008,MONTH=5,WEEK_OF_YEAR=25,WEEK_OF_MONTH=3,DAY_OF_MONTH=18,DAY_OF_YEAR=170,DAY_OF_WEEK=4,DAY_OF_WEEK_IN_MONTH=3,AM_PM=0,HOUR=9,HOUR_OF_DAY=9,MINUTE=5,SECOND=0,MILLISECOND=0,ZONE_OFFSET=0,DST_OFFSET=0]




This is how a field of type DATE/TIME got displayed in a data table... I am using a custom controller to query the database and get this value.. Do i need to do any type conversion to display this date in proper format

Thanks
dchasmandchasman
It looks like you are just dumping out the raw date using a value expression like {!theDate} (can't tell because you did not include your page's markup) and switching to using an apex:outputField component will give you the correct locale aware formatting.
Edwin VijayEdwin Vijay
Its working fine now... i did not change anything.. dont know what would have been the reason.... is there a way to avoid such problems in the future


Thanks
dchasmandchasman
"Its working fine now... I did not change anything.. dont know what would have been the reason..." - that does not really give me anything to go on so I have nothing to suggest w.r.t. avoiding such problems in the future.
kmccollkmccoll
I had a similar issue a while back... the raw output was inconsistently causing issues but using outputField fixed it

Thread here

No idea if it's fixed yet, but I did consider it a bug, albeit pretty low priority.
Edwin VijayEdwin Vijay
Hi Doug,

<apex:dataTable value="{!results}" var="res" cellpadding="3" cellspacing="0" border="1" id="table">
<apex:column ><apex:facet name="header">Submitted Date</apex:facet>&nbsp;{!res.Submitted_Date__c}</apex:column>
</apex:dataTable>

This is the code i used for displaying a field of type date/time...

The first time i saved this page i got the following value in place of SUBMITTED DATE...
java.util.GregorianCalendar[time=1213779900000,areFieldsSet=true,areAllFieldsSet=true,lenient=true,zone=sun.util.calendar.ZoneInfo[id="GMT",offset=0,dstSavings=0,useDaylight=false,transitions=0,lastRule=null],firstDayOfWeek=1,minimalDaysInFirstWeek=1,ERA=1,YEAR=2008,MONTH=5,WEEK_OF_YEAR=25,WEEK_OF_MONTH=3,DAY_OF_MONTH=18,DAY_OF_YEAR=170,DAY_OF_WEEK=4,DAY_OF_WEEK_IN_MONTH=3,AM_PM=0,HOUR=9,HOUR_OF_DAY=9,MINUTE=5,SECOND=0,MILLISECOND=0,ZONE_OFFSET=0,DST_OFFSET=0]

I opened the same VF page after some time... and i got the desired output...

What would be your suggestions for this...

Thanks,
Edwin

dchasmandchasman
Use <apex:outputField> - not sure why the free expression {!} changed its behavior and I have been unable to repro this - but you are better off using outputField in this case because it will produce values formatted in a user locale aware way.