Conversion issue for locale pt_BR

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Conversion issue for locale pt_BR

Rodrigo Canabrava
Hello everyone,

I am using Joda Time for the first time in a project, and I faced an
issue, here.
I wrote the following test:

    @Test
    public void testConversion() {
        LocalDate localDate = new LocalDate(2008, 1, 20);
        String dateString =
localDate.toString(DateTimeFormat.shortDate().withLocale(new
Locale("pt_BR")));
        assertEquals("20/1/08", dateString);
    }

As you can see, I expected the date to be converted using the pattern
'dd/MM/yyyy', since this is the correct for the Brazilian locale.
Nevertheless, the DateTimeFormat converted it using the pattern of the
United States ('MM/dd/yyyy'), which results in failure of my test.
I checked that even the system in which I'm running has the locale pt_BR.
Is there a reason why this is not using the correct pattern for my locale?

Regards,
Rodrigo

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Joda-interest mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/joda-interest
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Conversion issue for locale pt_BR

jodastephen
Joda-Time uses the java data to provide the formats. So, you need to
check that they are available and loaded correctly.

It may be that there is no java format defined for "pt_BR", and only for
"pt".

Otherwise, I suggest downloading the source, and stepping through with a
debugger.

Stephen



Rodrigo Canabrava wrote:

> Hello everyone,
>
> I am using Joda Time for the first time in a project, and I faced an
> issue, here.
> I wrote the following test:
>
>     @Test
>     public void testConversion() {
>         LocalDate localDate = new LocalDate(2008, 1, 20);
>         String dateString =
> localDate.toString(DateTimeFormat.shortDate().withLocale(new
> Locale("pt_BR")));
>         assertEquals("20/1/08", dateString);
>     }
>
> As you can see, I expected the date to be converted using the pattern
> 'dd/MM/yyyy', since this is the correct for the Brazilian locale.
> Nevertheless, the DateTimeFormat converted it using the pattern of the
> United States ('MM/dd/yyyy'), which results in failure of my test.
> I checked that even the system in which I'm running has the locale pt_BR.
> Is there a reason why this is not using the correct pattern for my locale?
>
> Regards,
> Rodrigo
>
> -------------------------------------------------------------------------
> This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
> Build the coolest Linux based applications with Moblin SDK & win great prizes
> Grand prize is a trip for two to an Open Source event anywhere in the world
> http://moblin-contest.org/redirect.php?banner_id=100&url=/
> _______________________________________________
> Joda-interest mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/joda-interest
>

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Joda-interest mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/joda-interest
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Conversion issue for locale pt_BR

Rodrigo Canabrava
Indeed, I implemented the same test for java.text.DateFormat, and the
results were the same. So I downloaded a JDK 1.4 and it worked with
it. So I need to report a bug for the jdk 6.0, which disappeared with
the brazilian locale.

Thanks,
Rodrigo


2008/9/20 Stephen Colebourne <[hidden email]>:

> Joda-Time uses the java data to provide the formats. So, you need to
> check that they are available and loaded correctly.
>
> It may be that there is no java format defined for "pt_BR", and only for
> "pt".
>
> Otherwise, I suggest downloading the source, and stepping through with a
> debugger.
>
> Stephen
>
>
>
> Rodrigo Canabrava wrote:
>> Hello everyone,
>>
>> I am using Joda Time for the first time in a project, and I faced an
>> issue, here.
>> I wrote the following test:
>>
>>     @Test
>>     public void testConversion() {
>>         LocalDate localDate = new LocalDate(2008, 1, 20);
>>         String dateString =
>> localDate.toString(DateTimeFormat.shortDate().withLocale(new
>> Locale("pt_BR")));
>>         assertEquals("20/1/08", dateString);
>>     }
>>
>> As you can see, I expected the date to be converted using the pattern
>> 'dd/MM/yyyy', since this is the correct for the Brazilian locale.
>> Nevertheless, the DateTimeFormat converted it using the pattern of the
>> United States ('MM/dd/yyyy'), which results in failure of my test.
>> I checked that even the system in which I'm running has the locale pt_BR.
>> Is there a reason why this is not using the correct pattern for my locale?
>>
>> Regards,
>> Rodrigo
>>
>> -------------------------------------------------------------------------
>> This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
>> Build the coolest Linux based applications with Moblin SDK & win great prizes
>> Grand prize is a trip for two to an Open Source event anywhere in the world
>> http://moblin-contest.org/redirect.php?banner_id=100&url=/
>> _______________________________________________
>> Joda-interest mailing list
>> [hidden email]
>> https://lists.sourceforge.net/lists/listinfo/joda-interest
>>
>
> -------------------------------------------------------------------------
> This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
> Build the coolest Linux based applications with Moblin SDK & win great prizes
> Grand prize is a trip for two to an Open Source event anywhere in the world
> http://moblin-contest.org/redirect.php?banner_id=100&url=/
> _______________________________________________
> Joda-interest mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/joda-interest
>

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Joda-interest mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/joda-interest
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Conversion issue for locale pt_BR

Michael Nascimento
I guess you actually meant new Locale("pt", "BR") instead of "pt_BR",
didn't you?

Regards,
Michael Nascimento Santos
https://genesis.dev.java.net/
https://jsr-310.dev.java.net/

On Thu, Sep 25, 2008 at 11:46 AM, Rodrigo Canabrava <[hidden email]> wrote:

> Indeed, I implemented the same test for java.text.DateFormat, and the
> results were the same. So I downloaded a JDK 1.4 and it worked with
> it. So I need to report a bug for the jdk 6.0, which disappeared with
> the brazilian locale.
>
> Thanks,
> Rodrigo
>
>
> 2008/9/20 Stephen Colebourne <[hidden email]>:
>> Joda-Time uses the java data to provide the formats. So, you need to
>> check that they are available and loaded correctly.
>>
>> It may be that there is no java format defined for "pt_BR", and only for
>> "pt".
>>
>> Otherwise, I suggest downloading the source, and stepping through with a
>> debugger.
>>
>> Stephen
>>
>>
>>
>> Rodrigo Canabrava wrote:
>>> Hello everyone,
>>>
>>> I am using Joda Time for the first time in a project, and I faced an
>>> issue, here.
>>> I wrote the following test:
>>>
>>>     @Test
>>>     public void testConversion() {
>>>         LocalDate localDate = new LocalDate(2008, 1, 20);
>>>         String dateString =
>>> localDate.toString(DateTimeFormat.shortDate().withLocale(new
>>> Locale("pt_BR")));
>>>         assertEquals("20/1/08", dateString);
>>>     }
>>>
>>> As you can see, I expected the date to be converted using the pattern
>>> 'dd/MM/yyyy', since this is the correct for the Brazilian locale.
>>> Nevertheless, the DateTimeFormat converted it using the pattern of the
>>> United States ('MM/dd/yyyy'), which results in failure of my test.
>>> I checked that even the system in which I'm running has the locale pt_BR.
>>> Is there a reason why this is not using the correct pattern for my locale?
>>>
>>> Regards,
>>> Rodrigo
>>>
>>> -------------------------------------------------------------------------
>>> This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
>>> Build the coolest Linux based applications with Moblin SDK & win great prizes
>>> Grand prize is a trip for two to an Open Source event anywhere in the world
>>> http://moblin-contest.org/redirect.php?banner_id=100&url=/
>>> _______________________________________________
>>> Joda-interest mailing list
>>> [hidden email]
>>> https://lists.sourceforge.net/lists/listinfo/joda-interest
>>>
>>
>> -------------------------------------------------------------------------
>> This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
>> Build the coolest Linux based applications with Moblin SDK & win great prizes
>> Grand prize is a trip for two to an Open Source event anywhere in the world
>> http://moblin-contest.org/redirect.php?banner_id=100&url=/
>> _______________________________________________
>> Joda-interest mailing list
>> [hidden email]
>> https://lists.sourceforge.net/lists/listinfo/joda-interest
>>
>
> -------------------------------------------------------------------------
> This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
> Build the coolest Linux based applications with Moblin SDK & win great prizes
> Grand prize is a trip for two to an Open Source event anywhere in the world
> http://moblin-contest.org/redirect.php?banner_id=100&url=/
> _______________________________________________
> Joda-interest mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/joda-interest
>

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Joda-interest mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/joda-interest
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Conversion issue for locale pt_BR

Rodrigo Canabrava
Well, I had done it wrong. But strange enough, the wrong way works in
the JDK 1.4.

I guess the behavior changed when VM doesn't find a match for the locale.
In the jdk1.4, it uses the system locale. Now, it doesn't. :|

Thank you Michael


2008/9/25 Michael Nascimento <[hidden email]>:

> I guess you actually meant new Locale("pt", "BR") instead of "pt_BR",
> didn't you?
>
> Regards,
> Michael Nascimento Santos
> https://genesis.dev.java.net/
> https://jsr-310.dev.java.net/
>
> On Thu, Sep 25, 2008 at 11:46 AM, Rodrigo Canabrava <[hidden email]> wrote:
>> Indeed, I implemented the same test for java.text.DateFormat, and the
>> results were the same. So I downloaded a JDK 1.4 and it worked with
>> it. So I need to report a bug for the jdk 6.0, which disappeared with
>> the brazilian locale.
>>
>> Thanks,
>> Rodrigo
>>
>>
>> 2008/9/20 Stephen Colebourne <[hidden email]>:
>>> Joda-Time uses the java data to provide the formats. So, you need to
>>> check that they are available and loaded correctly.
>>>
>>> It may be that there is no java format defined for "pt_BR", and only for
>>> "pt".
>>>
>>> Otherwise, I suggest downloading the source, and stepping through with a
>>> debugger.
>>>
>>> Stephen
>>>
>>>
>>>
>>> Rodrigo Canabrava wrote:
>>>> Hello everyone,
>>>>
>>>> I am using Joda Time for the first time in a project, and I faced an
>>>> issue, here.
>>>> I wrote the following test:
>>>>
>>>>     @Test
>>>>     public void testConversion() {
>>>>         LocalDate localDate = new LocalDate(2008, 1, 20);
>>>>         String dateString =
>>>> localDate.toString(DateTimeFormat.shortDate().withLocale(new
>>>> Locale("pt_BR")));
>>>>         assertEquals("20/1/08", dateString);
>>>>     }
>>>>
>>>> As you can see, I expected the date to be converted using the pattern
>>>> 'dd/MM/yyyy', since this is the correct for the Brazilian locale.
>>>> Nevertheless, the DateTimeFormat converted it using the pattern of the
>>>> United States ('MM/dd/yyyy'), which results in failure of my test.
>>>> I checked that even the system in which I'm running has the locale pt_BR.
>>>> Is there a reason why this is not using the correct pattern for my locale?
>>>>
>>>> Regards,
>>>> Rodrigo
>>>>
>>>> -------------------------------------------------------------------------
>>>> This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
>>>> Build the coolest Linux based applications with Moblin SDK & win great prizes
>>>> Grand prize is a trip for two to an Open Source event anywhere in the world
>>>> http://moblin-contest.org/redirect.php?banner_id=100&url=/
>>>> _______________________________________________
>>>> Joda-interest mailing list
>>>> [hidden email]
>>>> https://lists.sourceforge.net/lists/listinfo/joda-interest
>>>>
>>>
>>> -------------------------------------------------------------------------
>>> This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
>>> Build the coolest Linux based applications with Moblin SDK & win great prizes
>>> Grand prize is a trip for two to an Open Source event anywhere in the world
>>> http://moblin-contest.org/redirect.php?banner_id=100&url=/
>>> _______________________________________________
>>> Joda-interest mailing list
>>> [hidden email]
>>> https://lists.sourceforge.net/lists/listinfo/joda-interest
>>>
>>
>> -------------------------------------------------------------------------
>> This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
>> Build the coolest Linux based applications with Moblin SDK & win great prizes
>> Grand prize is a trip for two to an Open Source event anywhere in the world
>> http://moblin-contest.org/redirect.php?banner_id=100&url=/
>> _______________________________________________
>> Joda-interest mailing list
>> [hidden email]
>> https://lists.sourceforge.net/lists/listinfo/joda-interest
>>
>
> -------------------------------------------------------------------------
> This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
> Build the coolest Linux based applications with Moblin SDK & win great prizes
> Grand prize is a trip for two to an Open Source event anywhere in the world
> http://moblin-contest.org/redirect.php?banner_id=100&url=/
> _______________________________________________
> Joda-interest mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/joda-interest
>

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Joda-interest mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/joda-interest
Loading...