I am having that bug where the attribute table and the attribute inspector show the dates as one day earlier. I found a possible solution on the web but there is an error in the following line because the attribute inspector has no "form" property. Is there any way to get around this? Thankserror in this line var formItems:* = editor.attributeInspector.form.getChildren();
/ Place the following code below the function populateEditor
private var dateFormatter:DateFormatter = new DateFormatter();
private const newDateFormat:String = �??DD/MM/YYYY�?�;
private function attributeInspector_showFeatureHandler(event:AttributeInspectorEvent):void
{
formatDateFieldDisplay(event);
}
private function attributeInspector_updateFeatureHandler(event:AttributeInspectorEvent):void
{
formatDateFieldDisplay(event);
}
private function formatDateFieldDisplay(event:AttributeInspectorEvent):void
{
if(!(event.featureLayer && event.feature && event.feature.attributes))
return;
// This ensures that we only validate when we are working at a field level
(not an AttributeInspector level)
if(event.field)
{
if(event.field.type == Field.TYPE_DATE)
{
if(event.newValue) // If it comes exclusively from an update �?� format the display
{
// Change the date format as desired
event.target.formatString = newDateFormat;
}
}
}
else if(event.type.toLowerCase() == �??showfeature�?�)
{
var formItems:* = editor.attributeInspector.form.getChildren();
// Loop items and trigger update event
for (var i:Number = 0; i < formItems.length; i++)
{
if(formItems.data && formItems.data is Field)
{
var field:Field = formItems.data;
if(field.type == Field.TYPE_DATE &&
field.name in event.feature.attributes &&
event.feature.attributes[field.name])
{
var event:AttributeInspectorEvent = new AttributeInspectorEvent(�??updateFeature�?�,
true,
event.featureLayer,
event.feature,
field,
event.feature.attributes[field.name],
event.feature.attributes[field.name]);
var formItem:* = formItems.getChildren();
if(formItem && formItem.length > 0)
formItem[0].dispatchEvent(event);
}
}
}
}
}
// This function should be in a separate util file to be reused if necessary by other classes.
// This function comes with the ArcGIS Viewer for Flex 2.4.
// If Esri updates this function so should the developer.
private function msToDate(ms:Number, dateFormat:String, useUTC:Boolean):String
{
var date:Date = new Date(ms);
if (date.milliseconds == 999) // Workaround for REST bug
date.milliseconds++;
if (useUTC)
date.minutes += date.timezoneOffset;
if (dateFormat)
{
dateFormatter.formatString = dateFormat;
var result:String = dateFormatter.format(date);
if (result)
return result;
else
return dateFormatter.error;
}
else
{
return date.toLocaleString();
}
}
Source:http://pm4gis.wordpress.com/2011/09/15/change-the-date-format-of-the-attributeinspector-editwidget-m...