Server Upgrade to 10- dates in FlexViewer appear incorrectly

1348
3
Jump to solution
02-09-2012 05:09 AM
by Anonymous User
Not applicable
Original User: ctalleygreenville

Hello all,

We are finally able to upgrade Server to 10.  Our SDE data will have to remain at 9.3 for a little while longer.  After the upgrade, the dates appear incorrectly in our FlexViewer app.  This app was created 2+ yrs ago with v. 1.3 API and most of the widgets were further customized from the default.  In what was the Live Layer Widget, the dates appear incorrectly with 10.  We notice that the rest services are returning slightly different information also between html and json.  I have also seen the forums about the time being reported as UTC but not sure what to do with 1.3.

Before upgrade with good dates:
[ATTACH=CONFIG]11832[/ATTACH]

After upgrade with bad dates:
[ATTACH=CONFIG]11833[/ATTACH]

Is there a fix for this that won't require reworking everything to the new FlexViewer based on current API?  I know, I know, you are thinking, "what are you doing still using a 1.3 app?"  We really customized the code at the time and there were no plans to add any more functionality, so we were hoping to not have to re-work it to use current API until we absolutely had to.  I hope this isn't the time we absolutely have to!

Thanks,
Carmen
0 Kudos
1 Solution

Accepted Solutions
RobertScheitlin__GISP
MVP Emeritus
Carmen,

  All you need to do is run the values return for those dates through this function:

            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();                 }             }


You will also need this declaration:

<fx:Declarations><mx:DateFormatter id="iDateFormat" /></fx:Declarations>


Don't forget to click the Mark as answer check and to click the top arrow (promote) as shown below:

View solution in original post

0 Kudos
3 Replies
RobertScheitlin__GISP
MVP Emeritus
Carmen,

  All you need to do is run the values return for those dates through this function:

            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();                 }             }


You will also need this declaration:

<fx:Declarations><mx:DateFormatter id="iDateFormat" /></fx:Declarations>


Don't forget to click the Mark as answer check and to click the top arrow (promote) as shown below:
0 Kudos
by Anonymous User
Not applicable
Original User: ctalleygreenville

Robert,

Thank you, yet again.  This worked for me in two scenarios:

It solved the problem for the FlexViewer 1.3 (3.5 SDK or something like that) app.  Where I only used
<mx: DateForematter id="dateFormatter" /> vs. including the fx: Declaration since this was using 3.5 SDK.

This also worked for a popup Window that contained a similar date within a non-flexviewer app using 2.5API and 4.0 SDK.  In this case, I used everything the same as you indicated.

The forums keep changing - guess we better attend that session at the Developers conference! ha.

Carmen
0 Kudos
AlexZhuk
Regular Contributor
While the issue was fixed in the Attribute Table widget in Flex Viewer 3.4, the pop-up widget still shows time incorrectly.
0 Kudos