Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Adobe AIR Development

Reply
New Developer
MissRancher
Posts: 55
Registered: ‎11-10-2009
My Device: Not Specified

How to format Date output

I need to format a Date as such: %Y-%m-%dT%H:%M:%S.000Z

 

But I can't figure out how......any help?

Please use plain text.
Developer
bradcarvey
Posts: 17
Registered: ‎11-22-2010
My Device: PlayBook

Re: How to format Date output

 

var df:smileyvery-happy:ateFormatter = new DateFormatter();
df.formatString = "MM/DD/YYYY";
var formattedDate:String = df.format(myUnformattedString);

 

Please use plain text.
Developer
gluth
Posts: 192
Registered: ‎09-23-2009
My Device: 9860/PlayBook/Dev Alpha
My Carrier: Plus GSM

Re: How to format Date output

[ Edited ]

As I see you want to have Data in ISO format, all fields with exception for TimeZone adjustment you can output with DateFormatter example above, timezone adjustment you will find in Date object from which you must manually attach to the formatted string.

 

var d: Date = new Date();

var df: DateFormatter = new DateFormatter();

var formattedTime:smileyfrustrated:tring = df.format("YYYY-MM-DDTJJ:NN:smileyfrustrated:S");

if(d.timezoneOffset != 0) {

 if(d.timezoneOffset > 0) {

  formattedTime += "+";

 }

 formattedTime += (d.timzezoneOffset/60) + ":" +(d.timzezoneOffset%60) ;

}

Found my post helpfull? Like it! It solves your trouble? Help others and accept it as solution. Search before asking.
My apps: Secret Cod3s | Should my tablet be banned?
--
Jakub Nietrzeba
PGS Software S.A.
Your reliable partner in Poland - IT Outsourcing - BlackBerry, iPhone, Web and Standalone applications
Please use plain text.
New Developer
david_schwartz_bb
Posts: 137
Registered: ‎02-04-2010
My Device: Tour 9630
My Carrier: verizon

Re: How to format Date output

Which library is DateFormatter located? Thanks
Please use plain text.
Developer
kdittyr
Posts: 278
Registered: ‎10-27-2010
My Device: Playbook

Re: How to format Date output

 


david_schwartz_bb wrote:
Which library is DateFormatter located? Thanks

mx.formatters.DateFormatter

 

--------------
kdittyr

Accepted PlayBook Applications:
HDB Converter -- Utilities/Calculators
Please use plain text.
New Developer
david_schwartz_bb
Posts: 137
Registered: ‎02-04-2010
My Device: Tour 9630
My Carrier: verizon

Re: How to format Date output

This is working well for me. Any known issues? import flash.globalization.DateTimeFormatter; import flash.globalization.DateTimeStyle; var df:smileyvery-happy:ateTimeFormatter = new DateTimeFormatter("English (US)"); df.setDateTimeStyles(DateTimeStyle.SHORT, DateTimeStyle.NONE); var curDate:smileyfrustrated:tring = df.format(new Date());
Please use plain text.