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
kmccollkmccoll 

datetime issue

I'm seeing an odd issue when displaying datetime values.

My (simplified) code is as follows:
Code:
public class testdateController {
 public Event[] getDates() {
         
        return [ SELECT Id, 
   ActivityDateTime
  FROM Event
  ORDER BY ActivityDateTime
  LIMIT 8 ];
    }
}

<apex:page controller="testdateController" showHeader="false" sidebar="false">
 <apex:dataTable value="{!dates}" var="each" cellpadding="6"  id="scheduleTable">
  <apex:column>
   <apex:facet name="header">Start Time</apex:facet>
   <apex:outputText value="{!each.ActivityDateTime}"/>
  </apex:column>                
    </apex:dataTable>
</apex:page>

This runs okay sometimes:
Code:
Start Time
Thu Feb 15 00:55:00 GMT 2007
Thu Mar 01 02:00:00 GMT 2007
Wed Apr 25 17:00:00 GMT 2007
Wed Feb 20 19:37:00 GMT 2008
Tue Feb 26 18:56:00 GMT 2008
Tue Feb 26 18:57:00 GMT 2008
(Although datetime values not being formatted)

But other times, gives java code instead of the datetimes:
Code:
Start Time
java.util.GregorianCalendar[time=1171500900000,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=2007,MONTH=1,WEEK_OF_YEAR=7,WEEK_OF_MONTH=3,DAY_OF_MONTH=15,DAY_OF_YEAR=46,DAY_OF_WEEK=5,DAY_OF_WEEK_IN_MONTH=3,AM_PM=0,HOUR=0,HOUR_OF_DAY=0,MINUTE=55,SECOND=0,MILLISECOND=0,ZONE_OFFSET=0,DST_OFFSET=0]
java.util.GregorianCalendar[time=1172714400000,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=2007,MONTH=2,WEEK_OF_YEAR=9,WEEK_OF_MONTH=1,DAY_OF_MONTH=1,DAY_OF_YEAR=60,DAY_OF_WEEK=5,DAY_OF_WEEK_IN_MONTH=1,AM_PM=0,HOUR=2,HOUR_OF_DAY=2,MINUTE=0,SECOND=0,MILLISECOND=0,ZONE_OFFSET=0,DST_OFFSET=0]
java.util.GregorianCalendar[time=1177520400000,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=2007,MONTH=3,WEEK_OF_YEAR=17,WEEK_OF_MONTH=4,DAY_OF_MONTH=25,DAY_OF_YEAR=115,DAY_OF_WEEK=4,DAY_OF_WEEK_IN_MONTH=4,AM_PM=1,HOUR=5,HOUR_OF_DAY=17,MINUTE=0,SECOND=0,MILLISECOND=0,ZONE_OFFSET=0,DST_OFFSET=0]
java.util.GregorianCalendar[time=1203536220000,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=1,WEEK_OF_YEAR=8,WEEK_OF_MONTH=4,DAY_OF_MONTH=20,DAY_OF_YEAR=51,DAY_OF_WEEK=4,DAY_OF_WEEK_IN_MONTH=3,AM_PM=1,HOUR=7,HOUR_OF_DAY=19,MINUTE=37,SECOND=0,MILLISECOND=0,ZONE_OFFSET=0,DST_OFFSET=0]
java.util.GregorianCalendar[time=1204052160000,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=1,WEEK_OF_YEAR=9,WEEK_OF_MONTH=5,DAY_OF_MONTH=26,DAY_OF_YEAR=57,DAY_OF_WEEK=3,DAY_OF_WEEK_IN_MONTH=4,AM_PM=1,HOUR=6,HOUR_OF_DAY=18,MINUTE=56,SECOND=0,MILLISECOND=0,ZONE_OFFSET=0,DST_OFFSET=0]

 I can't figure out what triggers this, but seems to happen about half of the time.

I'm pretty new at vf so there's a good chance I'm missing something basic.

Thanks
Kenny

 

 

jwetzlerjwetzler
Hmm.  I have not seen the java issue.  Trying to reproduce it on my end but I can't seem to.  Not sure what's causing that.

Is there a reason you are using outputText as opposed to outputField?  outputField will format the value for you.

Jill
kmccollkmccoll
No reason other than newbiness...

I changed it to outputField and it seems to gets around the problem for me.   I just tried 10 refreshes - the outputText column failed 9 times; the outputField column worked every time.

Thanks.