Reputation: 1008
I am formatting the current date in an AIR Mobile project in the following way:
var dateFormatter:DateTimeFormatter = new DateTimeFormatter( Capabilities.language );
dateFormatter.setDateTimePattern("EEEE d");
trace(dateFormatter.format(date));
This works perfect, but since I have a width restriction (only 12 characters can be displayed) the problem is that in certain languages like Portuguese, the EEEE format returns Segunda-feria
meaning that the number of characters would be 16 (including day number).
Is there a way to put conditional formatting meaning that EEEE cannot exceed more than 10 characters? (i.e: use EEEE always but if it exceeds more than 12 characters display EEE)
Upvotes: 1
Views: 63
Reputation: 15926
Try something like this:
var str_tmp: String ="";
var dateFormatter :DateTimeFormatter = new DateTimeFormatter( Capabilities.language );
dateFormatter.setDateTimePattern("EEEE d");
//# check for larger than 12 chars
str_tmp = dateFormatter.format(date);
if ( str_tmp.length > 12 ) { dateFormatter.setDateTimePattern("EEE d"); }
trace(dateFormatter.format(date));
Upvotes: 2