<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Flex local dates/time transfer issue</title>
	<atom:link href="http://flexblog.faratasystems.com/2008/02/05/flex-local-datestime-transfer-issue/feed" rel="self" type="application/rss+xml" />
	<link>http://flexblog.faratasystems.com/2008/02/05/flex-local-datestime-transfer-issue</link>
	<description>A blog about our experience with Adobe Flex</description>
	<lastBuildDate>Sun, 15 Jan 2012 16:29:29 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Nishant Mistry</title>
		<link>http://flexblog.faratasystems.com/2008/02/05/flex-local-datestime-transfer-issue/comment-page-1#comment-99292</link>
		<dc:creator>Nishant Mistry</dc:creator>
		<pubDate>Thu, 11 Aug 2011 06:51:05 +0000</pubDate>
		<guid isPermaLink="false">http://flexblog.faratasystems.com/?p=289#comment-99292</guid>
		<description>i am working on flex date. I am facing a small issue with that.

Flex date starts with 1st jan, 1970 and i want to make it start from 1st Jan, 1960.

for that.. i have written some code.. but its behaving perfect in some locales and for some locales, it&#039;s not. (specifically for the ones which has daylight saving. )

Can anyone suggest, is can this be a locale issue ? or the code one?

the sample is code is below.

var d:Date = new Date(2008, 4, 1); // May 1, 2008
var baseDateTime:Number = flexDateToBaseDate(d.getTime()); // this function will convert the base of date d from 1st Jan, 1970 to 1st Jan, 1960 and convert it in the number of miliseconds since then.


the function flexDateToBaseDate is as below.

 public  static function flexDateToBaseDate(dateNum:Number):int{
       
           return (dateNum - datediffOffset )/millisInDay;


datediffOffset is calculated as below

             _baseYear= 1960;
             _date = new Date( _baseYeas, 0, 1, 0, 0, 0, 0 );
             _datediffOffset= _date.getTime();

 var millisInDay:int = (24*60*60*1000);

can you please tell me, where am doing mistake?</description>
		<content:encoded><![CDATA[<p>i am working on flex date. I am facing a small issue with that.</p>
<p>Flex date starts with 1st jan, 1970 and i want to make it start from 1st Jan, 1960.</p>
<p>for that.. i have written some code.. but its behaving perfect in some locales and for some locales, it&#8217;s not. (specifically for the ones which has daylight saving. )</p>
<p>Can anyone suggest, is can this be a locale issue ? or the code one?</p>
<p>the sample is code is below.</p>
<p>var d:Date = new Date(2008, 4, 1); // May 1, 2008<br />
var baseDateTime:Number = flexDateToBaseDate(d.getTime()); // this function will convert the base of date d from 1st Jan, 1970 to 1st Jan, 1960 and convert it in the number of miliseconds since then.</p>
<p>the function flexDateToBaseDate is as below.</p>
<p> public  static function flexDateToBaseDate(dateNum:Number):int{</p>
<p>           return (dateNum &#8211; datediffOffset )/millisInDay;</p>
<p>datediffOffset is calculated as below</p>
<p>             _baseYear= 1960;<br />
             _date = new Date( _baseYeas, 0, 1, 0, 0, 0, 0 );<br />
             _datediffOffset= _date.getTime();</p>
<p> var millisInDay:int = (24*60*60*1000);</p>
<p>can you please tell me, where am doing mistake?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mike C</title>
		<link>http://flexblog.faratasystems.com/2008/02/05/flex-local-datestime-transfer-issue/comment-page-1#comment-97722</link>
		<dc:creator>Mike C</dc:creator>
		<pubDate>Tue, 19 Jul 2011 14:11:42 +0000</pubDate>
		<guid isPermaLink="false">http://flexblog.faratasystems.com/?p=289#comment-97722</guid>
		<description>I use SQL Convert(varchar(10),dateField,101) as dateField to return date in format &quot;MM/DD/YYYY&quot;. Do not use date formatter in ActionScript and it works for me.</description>
		<content:encoded><![CDATA[<p>I use SQL Convert(varchar(10),dateField,101) as dateField to return date in format &#8220;MM/DD/YYYY&#8221;. Do not use date formatter in ActionScript and it works for me.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Antonio D</title>
		<link>http://flexblog.faratasystems.com/2008/02/05/flex-local-datestime-transfer-issue/comment-page-1#comment-92547</link>
		<dc:creator>Antonio D</dc:creator>
		<pubDate>Fri, 01 Apr 2011 08:03:03 +0000</pubDate>
		<guid isPermaLink="false">http://flexblog.faratasystems.com/?p=289#comment-92547</guid>
		<description>Hi, can you tell me why it is necessary to use transient also on java side ?
In my application I use the same DTO also to call a webService and if i set a property to transient this in not working.
Thanks</description>
		<content:encoded><![CDATA[<p>Hi, can you tell me why it is necessary to use transient also on java side ?<br />
In my application I use the same DTO also to call a webService and if i set a property to transient this in not working.<br />
Thanks</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Anatole Tartakovsky</title>
		<link>http://flexblog.faratasystems.com/2008/02/05/flex-local-datestime-transfer-issue/comment-page-1#comment-91755</link>
		<dc:creator>Anatole Tartakovsky</dc:creator>
		<pubDate>Fri, 11 Mar 2011 19:34:48 +0000</pubDate>
		<guid isPermaLink="false">http://flexblog.faratasystems.com/?p=289#comment-91755</guid>
		<description>David,
You need it in 2 directions - no headers on the retrieve -  thus client code is preferred. You might need it on some fields, and not the others - hence transient getters/setters. Finally, if you are for server only solution, you can use IP to address DB to get rid of the extra headers and make it symmetrical - we do it for more advanced localization - be careful with mobile platforms though. 
Regards
Anatole Tartakovsky</description>
		<content:encoded><![CDATA[<p>David,<br />
You need it in 2 directions &#8211; no headers on the retrieve &#8211;  thus client code is preferred. You might need it on some fields, and not the others &#8211; hence transient getters/setters. Finally, if you are for server only solution, you can use IP to address DB to get rid of the extra headers and make it symmetrical &#8211; we do it for more advanced localization &#8211; be careful with mobile platforms though.<br />
Regards<br />
Anatole Tartakovsky</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: David Weinberg</title>
		<link>http://flexblog.faratasystems.com/2008/02/05/flex-local-datestime-transfer-issue/comment-page-1#comment-91384</link>
		<dc:creator>David Weinberg</dc:creator>
		<pubDate>Mon, 07 Mar 2011 23:03:04 +0000</pubDate>
		<guid isPermaLink="false">http://flexblog.faratasystems.com/?p=289#comment-91384</guid>
		<description>A bit late on this one, but here is what I am doing so I can make the change for all dates.

Flex:
Use a custom Channel that overrides send:
message.headers[&quot;timezoneOffset&quot;] = new Date().getTimezoneOffset();

Java:
Use a custom java adapter that overrides invoke:
        int serverOffset = Calendar.getInstance().getTimeZone().getOffset(new Date().getTime())  / 1000 / 60 * -1;
        int clientOffset = (Integer) message.getHeader(&quot;timezoneOffset&quot;);
        if (serverOffset != clientOffset) {
            for (Object obj : ((RemotingMessage)message).getParameters()) {
                if (obj instanceof Date) {
                    Date date = (Date) obj;
                    Calendar cal = Calendar.getInstance();
                    cal.setTime(date);
                    cal.add(Calendar.MINUTE, serverOffset - clientOffset);
                    date.setTime(cal.getTimeInMillis());
                }
            }
        }</description>
		<content:encoded><![CDATA[<p>A bit late on this one, but here is what I am doing so I can make the change for all dates.</p>
<p>Flex:<br />
Use a custom Channel that overrides send:<br />
message.headers["timezoneOffset"] = new Date().getTimezoneOffset();</p>
<p>Java:<br />
Use a custom java adapter that overrides invoke:<br />
        int serverOffset = Calendar.getInstance().getTimeZone().getOffset(new Date().getTime())  / 1000 / 60 * -1;<br />
        int clientOffset = (Integer) message.getHeader(&#8220;timezoneOffset&#8221;);<br />
        if (serverOffset != clientOffset) {<br />
            for (Object obj : ((RemotingMessage)message).getParameters()) {<br />
                if (obj instanceof Date) {<br />
                    Date date = (Date) obj;<br />
                    Calendar cal = Calendar.getInstance();<br />
                    cal.setTime(date);<br />
                    cal.add(Calendar.MINUTE, serverOffset &#8211; clientOffset);<br />
                    date.setTime(cal.getTimeInMillis());<br />
                }<br />
            }<br />
        }</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Duchateau Olivier</title>
		<link>http://flexblog.faratasystems.com/2008/02/05/flex-local-datestime-transfer-issue/comment-page-1#comment-76955</link>
		<dc:creator>Duchateau Olivier</dc:creator>
		<pubDate>Tue, 24 Aug 2010 17:09:56 +0000</pubDate>
		<guid isPermaLink="false">http://flexblog.faratasystems.com/?p=289#comment-76955</guid>
		<description>Thank you ! 
I write your code in my two general method : setFormData(model) and getFormData(model) and it&#039;s perfect !
No need to write it on all dto&#039;s

Example : model  =
[RemoteClass(alias=&quot;org.ainflux.bdd.aintranet.evenement.Evenement&quot;)]
public class Evenement extends BaseObjectDao {
    [Bindable] //dateHeureFin 
    public var dateHeureFin : Date;
}

public function getFormData(model)  {
 ...code...
  if (property.substring(0,4) == &#039;date&#039;) {
      var dt : Date = widget.value as Date;
      model[property] =  new Date(dt.valueOf() - dt.getTimezoneOffset()*60000);
  }
 ...code...
}</description>
		<content:encoded><![CDATA[<p>Thank you !<br />
I write your code in my two general method : setFormData(model) and getFormData(model) and it&#8217;s perfect !<br />
No need to write it on all dto&#8217;s</p>
<p>Example : model  =<br />
[RemoteClass(alias="org.ainflux.bdd.aintranet.evenement.Evenement")]<br />
public class Evenement extends BaseObjectDao {<br />
    [Bindable] //dateHeureFin<br />
    public var dateHeureFin : Date;<br />
}</p>
<p>public function getFormData(model)  {<br />
 &#8230;code&#8230;<br />
  if (property.substring(0,4) == &#8216;date&#8217;) {<br />
      var dt : Date = widget.value as Date;<br />
      model[property] =  new Date(dt.valueOf() &#8211; dt.getTimezoneOffset()*60000);<br />
  }<br />
 &#8230;code&#8230;<br />
}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Anatole Tartakovsky</title>
		<link>http://flexblog.faratasystems.com/2008/02/05/flex-local-datestime-transfer-issue/comment-page-1#comment-75314</link>
		<dc:creator>Anatole Tartakovsky</dc:creator>
		<pubDate>Thu, 22 Jul 2010 06:21:03 +0000</pubDate>
		<guid isPermaLink="false">http://flexblog.faratasystems.com/?p=289#comment-75314</guid>
		<description>Ken,
2 Choices - either manually on DTO level rather then _generated one ( we generate 2 classes per DTO for generation gap pattern) or by modifying XSLT - either way it is quite simple.
Thank you
Anatole</description>
		<content:encoded><![CDATA[<p>Ken,<br />
2 Choices &#8211; either manually on DTO level rather then _generated one ( we generate 2 classes per DTO for generation gap pattern) or by modifying XSLT &#8211; either way it is quite simple.<br />
Thank you<br />
Anatole</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ken</title>
		<link>http://flexblog.faratasystems.com/2008/02/05/flex-local-datestime-transfer-issue/comment-page-1#comment-63162</link>
		<dc:creator>Ken</dc:creator>
		<pubDate>Thu, 04 Mar 2010 09:09:48 +0000</pubDate>
		<guid isPermaLink="false">http://flexblog.faratasystems.com/?p=289#comment-63162</guid>
		<description>This is useful, but how do you apply it when using Farata&#039;s DTO2FX to generate the AS DTO&#039;s from Java?  The adjusted DateUTC methods need to be manually written in the generated parent AS class, but they need to reference the data property in the generated child class.  Not sure how to get round this, without using @FXIgnore on all date fields and handling them manually.</description>
		<content:encoded><![CDATA[<p>This is useful, but how do you apply it when using Farata&#8217;s DTO2FX to generate the AS DTO&#8217;s from Java?  The adjusted DateUTC methods need to be manually written in the generated parent AS class, but they need to reference the data property in the generated child class.  Not sure how to get round this, without using @FXIgnore on all date fields and handling them manually.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

