Bug in date formatting for locale=SV

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

Bug in date formatting for locale=SV

William Brown
I believe that I've found a bug in date formatting for the Swedish locale. For full dates in Swedish, the CLDR pattern is:

<pattern>EEEE'en' 'den' d:'e' MMMM y</pattern>
Which means that today's date should be formatted as "fredag en den 5: augusti 2011". However, given the following Java code and JodaTime 2.0, I get a result of "den 5 augusti 2011":

import java.util.Locale;
import org.joda.time.DateTime;
import org.joda.time.format.DateTimeFormat;
import org.joda.time.format.DateTimeFormatter;

public class JodaTest {
  public static void main(String[] args) {
    DateTime time = new DateTime();
    Locale sv = new Locale("sv");
    DateTimeFormatter formatter = DateTimeFormat.longDate().withLocale(sv);
    System.out.println(formatter.print(time));
  }
}

According to CLDR, "den 5 augusti 2011" is not a valid date (although "5 augusti 2011" is). I tried to follow the codepath for date formatting, but didn't get very far; it looks like this might be the result of a bad import from CLDR, but I'm not sure.

I'm not sure what the process is for submitting patches is, but if given a prod in the right direction, I can go about making a patch.

Thanks!

Will

--
William Brown | Engineering, Google NYC | [hidden email] | <a href="tel:320-584-9293" value="+13205849293" target="_blank">320-584-9293


------------------------------------------------------------------------------
BlackBerry&reg; DevCon Americas, Oct. 18-20, San Francisco, CA
The must-attend event for mobile developers. Connect with experts.
Get tools for creating Super Apps. See the latest technologies.
Sessions, hands-on labs, demos & much more. Register early & save!
http://p.sf.net/sfu/rim-blackberry-1
_______________________________________________
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: Bug in date formatting for locale=SV

jodastephen
Hi,
Your email was classified as spam by gmail....

Joda-Time simply uses the JDK definitions of date formats.

        Locale sv = new Locale("sv");
        Locale.setDefault(sv);
        DateTime time = new DateTime();
        DateTimeFormatter formatter = DateTimeFormat.longDate();
        System.out.println(formatter.print(time));
        Date a = time.toDate();
        System.out.println(DateFormat.getDateInstance(DateFormat.LONG).format(a));

Thus, both system outs prduce the same string.

You can manually alter the JDK date format strings in JDK 6 and later
if that is what you want. If you want to add CLDR parsing to
Joda-Time, the repo is on GitHub ready to be forked...

Stephen



On 5 August 2011 16:32, William Brown <[hidden email]> wrote:

> I believe that I've found a bug in date formatting for the Swedish locale.
> For full dates in Swedish, the CLDR pattern is:
> <pattern>EEEE'en' 'den' d:'e' MMMM y</pattern>
> (http://unicode.org/cldr/trac/browser/tags/release-2-0-1/common/main/sv.xml#L1589)
>
> Which means that today's date should be formatted as "fredag en den 5:
> augusti 2011". However, given the following Java code and JodaTime 2.0, I
> get a result of "den 5 augusti 2011":
> import java.util.Locale;
> import org.joda.time.DateTime;
> import org.joda.time.format.DateTimeFormat;
> import org.joda.time.format.DateTimeFormatter;
> public class JodaTest {
>   public static void main(String[] args) {
>     DateTime time = new DateTime();
>     Locale sv = new Locale("sv");
>     DateTimeFormatter formatter = DateTimeFormat.longDate().withLocale(sv);
>     System.out.println(formatter.print(time));
>   }
> }
> According to CLDR, "den 5 augusti 2011" is not a valid date (although "5
> augusti 2011" is). I tried to follow the codepath for date formatting, but
> didn't get very far; it looks like this might be the result of a bad import
> from CLDR, but I'm not sure.
> I'm not sure what the process is for submitting patches is, but if given a
> prod in the right direction, I can go about making a patch.
> Thanks!
> Will
> --
> William Brown | Engineering, Google NYC | [hidden email] | 320-584-9293
>
> ------------------------------------------------------------------------------
> BlackBerry&reg; DevCon Americas, Oct. 18-20, San Francisco, CA
> The must-attend event for mobile developers. Connect with experts.
> Get tools for creating Super Apps. See the latest technologies.
> Sessions, hands-on labs, demos & much more. Register early & save!
> http://p.sf.net/sfu/rim-blackberry-1
> _______________________________________________
> Joda-interest mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/joda-interest
>
>

------------------------------------------------------------------------------
Get a FREE DOWNLOAD! and learn more about uberSVN rich system,
user administration capabilities and model configuration. Take
the hassle out of deploying and managing Subversion and the
tools developers use with it.
http://p.sf.net/sfu/wandisco-dev2dev
_______________________________________________
Joda-interest mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/joda-interest
Loading...