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
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?

Developer
Posts: 17
Registered: ‎11-22-2010
My Device: PlayBook

Re: How to format Date output

 

var dfSmiley Very HappyateFormatter = new DateFormatter();
df.formatString = "MM/DD/YYYY";
var formattedDate:String = df.format(myUnformattedString);

 

Developer
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 formattedTimeSmiley Frustratedtring = df.format("YYYY-MM-DDTJJ:NNSmiley FrustratedS");

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
New Developer
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
Developer
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
New Developer
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 dfSmiley Very HappyateTimeFormatter = new DateTimeFormatter("English (US)"); df.setDateTimeStyles(DateTimeStyle.SHORT, DateTimeStyle.NONE); var curDateSmiley Frustratedtring = df.format(new Date());