[
https://issues.apache.org/jira/browse/FLEX-33658?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13734367#comment-13734367
]
Justin Mclean commented on FLEX-33658:
--------------------------------------
Welcome to the wonderful world of international dates, some places use
MM/DD/YYYY and others DD/MM/YYYY.
If format is passed a string, it trys to work out if month or day should come
first like so.
var monthFirst:Boolean = year != -1;
if (format)
monthFirst = monthFirst || format.search("M") < format.search("D");
Basically if it not found something that is likely to be a year, it looks at
the format string to see if a month or day come first, but as your format
string doesn't contain days that check fails.
It might be possible to extend this and also take a guess based on the current
locale or change the logic above so that it only does the check when both M and
D are there.
Another solution is to change your format function to be like this:
private function monthDisplay(item:String):String
{
var df:DateFormatter = new DateFormatter()
df.formatString="MMM-YYYY";
return df.format(new Date(item));
}
Or by changing the format of your date strings to YYYY-MM-DD.
> Using the mx:DateFormatter in Actionscript no longer produces the same results
> ------------------------------------------------------------------------------
>
> Key: FLEX-33658
> URL: https://issues.apache.org/jira/browse/FLEX-33658
> Project: Apache Flex
> Issue Type: Bug
> Components: Advanced Data Grid
> Affects Versions: Apache Flex 4.10.0
> Reporter: William Page
>
> Here is the code…
> var j:int = 0;
> for (i=minNum;i<length;i++) {
> oColumnDef = new AdvancedDataGridColumn();
> oColumnDef.headerText =
> MonthDisplay(modelLocator.aryMonths.getItemAt(i).begDate);
> oColumnDef.dataField = "s"+[j+1];
> oColumnDef.width = 100;
> oColumnDef.labelFunction=dgCurFormat12
> oColumnDef.setStyle("textAlign","right")
> colArray.push(oColumnDef);
> j=j+1;
> }
> private function MonthDisplay(item:String):String{
>
> var df:DateFormatter = new DateFormatter()
> df.formatString="MMM-YYYY";
> return df.format(item);
> }
> aryMonths contains dates like these ('07/01/2013', '06/01/2013',
> '05/01/2013', '04/01/2013', '03/01/2013', etc)
> The header text ends up showing Jan-2013, Jan-2013, Jan-2013, Jan-2013,
> Jan-2013 etc)
> It seems that the DateFormatter is reading the date in reverse order
> Day-Month-Year when applying the format…Versus Month-Day-Year…Is there a way
> to resolve this without rewriting all my database scripts to reformat dates?
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira