I feel your pain. This was a large hassle. Don't know about flex but this was helpful for me in js:
Date.prototype.toFormattedDateString = function () {
return isNaN(this) ? 'NaN' :
[
_addLeadingZero(this.getUTCMonth() + 1),
_addLeadingZero(this.getUTCDate()),
this.getUTCFullYear()
].join('/');
};
Date.prototype.toFormattedDateTimeString = function () {
return isNaN(this) ? 'NaN' :
[
_addLeadingZero(this.getUTCMonth() + 1),
_addLeadingZero(this.getUTCDate()),
this.getUTCFullYear()
].join('/') + " " + _addLeadingZero(this.getUTCHours()) + ":" + _addLeadingZero(this.getUTCMinutes()) + ":" + _addLeadingZero(this.getUTCSeconds());
};