You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@flex.apache.org by Harbs <ha...@gmail.com> on 2015/07/27 10:49:07 UTC

DateTimeFormatter

I have an issue with the spark DateTimeFormatter:

I need to check that a date is properly formatted using the currently set locale settings.

This works very nicely for a US locale:
var str:String = "12/13/2015";
formatter.format(str) == str;

However, for European locales, this does not work because the format method blindly converts the string to a date using:
new Date(value);
The Date constructor assumes the month is before the day which is not true for those locales.
The mx DateFormatter class has a parseDateString function which converts the date string into a Date object using the current locale settings. The problem with DateFormatter is that the format spec is very different than the Spark one.

Is there something I’m missing, or is DateTimeFormatter missing some essential functionality?

Harbs

Re: DateTimeFormatter

Posted by Harbs <ha...@gmail.com>.
Thanks for the reminder.

It looks like I had removed your fix for the issue reported here: https://issues.apache.org/jira/browse/FLEX-34247

I don’t remember why. It looks like starting composition from where it was left off causes a RTE with TextBlock.createTextLine().

I’ll have to step through the code to refresh my memory. I’ll try to do that a bit later…

On Jul 27, 2015, at 4:46 PM, Alex Harui <ah...@adobe.com> wrote:

> BTW, will you have time to look at the TLF performance issue soon?


Re: DateTimeFormatter

Posted by Alex Harui <ah...@adobe.com>.

On 7/27/15, 1:49 AM, "Harbs" <ha...@gmail.com> wrote:

>I have an issue with the spark DateTimeFormatter:
>
>I need to check that a date is properly formatted using the currently set
>locale settings.
>
>This works very nicely for a US locale:
>var str:String = "12/13/2015";
>formatter.format(str) == str;
>
>However, for European locales, this does not work because the format
>method blindly converts the string to a date using:
>new Date(value);
>The Date constructor assumes the month is before the day which is not
>true for those locales.
>The mx DateFormatter class has a parseDateString function which converts
>the date string into a Date object using the current locale settings. The
>problem with DateFormatter is that the format spec is very different than
>the Spark one.
>
>Is there something I’m missing, or is DateTimeFormatter missing some
>essential functionality?

Well, yes, it is a formatter not a parser.  Looks like Flash doesn’t want
to take on the tokenizing task so you’ll have to build your own.  I think
you can get the locale format from
flash.globalization.DateFormatter.getDateTimePattern()

BTW, will you have time to look at the TLF performance issue soon?

-Alex