JodaTime 1.5.2, DateTimeFormatter and case sensitivity

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

JodaTime 1.5.2, DateTimeFormatter and case sensitivity

Ian McCall
I'm having a problem with case sensitivity in JodaTime 1.5.2. This can  
be reproduced with the following test class:


package com.astirion.jodatime.caseproblem;

import org.joda.time.LocalDate;
import org.joda.time.format.DateTimeFormat;
import org.joda.time.format.DateTimeFormatter;

public class JodaTimeCaseProblem {

        public static void main(String[] args) {
                parseDate("dd-MMM-y", "28-Jan-1972");
                parseDate("dd-MMM-y", "28-jAN-1972");
        }

        private static void parseDate(String pattern, String dateText) {
                DateTimeFormatter formatter = DateTimeFormat.forPattern(pattern);
                String logTextStem = String.format("%s with text %s", pattern,  
dateText);
               
                try {
                        LocalDate date = formatter.parseDateTime(dateText).toLocalDate();
                        System.out.println(logTextStem + " produced " + date);
                } catch(Exception e) {
                        System.err.println(logTextStem + " produced an exception");
                        e.printStackTrace();
                }
        }
}


The first date will go through as expected. The second, 28-jAN-1972,  
will throw an exception.

I've found this message in the archive:
http://sourceforge.net/mailarchive/message.php?msg_id=475D87B3.50701%40joda.org

...which states this problem was fixed in 1.5.1. Is anyone else having  
this trouble in 1.5.2?



Cheer,
Ian


-------------------------------------------------------------------------
Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW!
Studies have shown that voting for your favorite open source project,
along with a healthy diet, reduces your potential for chronic lameness
and boredom. Vote Now at http://www.sourceforge.net/community/cca08
_______________________________________________
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: JodaTime 1.5.2, DateTimeFormatter and case sensitivity

jodastephen
The fix supports text in the format defined by DateFormatSymbols, all
upper case and all lower case. It does not suuport weird mixed case
examples like jAN.

Stephen


Ian McCall wrote:

> I'm having a problem with case sensitivity in JodaTime 1.5.2. This can  
> be reproduced with the following test class:
>
>
> package com.astirion.jodatime.caseproblem;
>
> import org.joda.time.LocalDate;
> import org.joda.time.format.DateTimeFormat;
> import org.joda.time.format.DateTimeFormatter;
>
> public class JodaTimeCaseProblem {
>
> public static void main(String[] args) {
> parseDate("dd-MMM-y", "28-Jan-1972");
> parseDate("dd-MMM-y", "28-jAN-1972");
> }
>
> private static void parseDate(String pattern, String dateText) {
> DateTimeFormatter formatter = DateTimeFormat.forPattern(pattern);
> String logTextStem = String.format("%s with text %s", pattern,  
> dateText);
>
> try {
> LocalDate date = formatter.parseDateTime(dateText).toLocalDate();
> System.out.println(logTextStem + " produced " + date);
> } catch(Exception e) {
> System.err.println(logTextStem + " produced an exception");
> e.printStackTrace();
> }
> }
> }
>
>
> The first date will go through as expected. The second, 28-jAN-1972,  
> will throw an exception.
>
> I've found this message in the archive:
> http://sourceforge.net/mailarchive/message.php?msg_id=475D87B3.50701%40joda.org
>
> ...which states this problem was fixed in 1.5.1. Is anyone else having  
> this trouble in 1.5.2?
>
>
>
> Cheer,
> Ian
>
>
> -------------------------------------------------------------------------
> Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW!
> Studies have shown that voting for your favorite open source project,
> along with a healthy diet, reduces your potential for chronic lameness
> and boredom. Vote Now at http://www.sourceforge.net/community/cca08
> _______________________________________________
> Joda-interest mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/joda-interest
>

-------------------------------------------------------------------------
Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW!
Studies have shown that voting for your favorite open source project,
along with a healthy diet, reduces your potential for chronic lameness
and boredom. Vote Now at http://www.sourceforge.net/community/cca08
_______________________________________________
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: JodaTime 1.5.2, DateTimeFormatter and case sensitivity

Ian McCall
In reply to this post by Ian McCall


Message: 1
Date: Tue, 08 Jul 2008 23:32:36 +0100
From: Stephen Colebourne <[hidden email]>
Subject: Re: [Joda-interest] JodaTime 1.5.2, DateTimeFormatter and
case sensitivity
To: Discussion of the Joda project
<[hidden email]>
Message-ID: <[hidden email]>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed

The fix supports text in the format defined by DateFormatSymbols, all
upper case and all lower case. It does not suuport weird mixed case
examples like jAN.

Thanks for the clarification - easy enough to fix with a toLower() call obviously, however I noticed it due to a change in behaviour accepting some dates received in XML messages from Excel (hence the odd formatting - bet it's some odd auto-correction corruption). 


Ian

-------------------------------------------------------------------------
Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW!
Studies have shown that voting for your favorite open source project,
along with a healthy diet, reduces your potential for chronic lameness
and boredom. Vote Now at http://www.sourceforge.net/community/cca08
_______________________________________________
Joda-interest mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/joda-interest
Loading...