Thanks for the response.  Using the LenientChronology prevents the
exception from occurring. However it will convert Week 54 2009 to back
to Week 1 of 2010.


        DateTimeFormatter parseFormat =
DateTimeFormat.forPattern("xxxx'W'ww");
        Chronology lenient =
            LenientChronology.getInstance(ISOChronology.getInstance());
        parseFormat = parseFormat.withChronology(lenient);


        DateTime dateTime = parseFormat.parseDateTime("2009W54");
        DateTimeFormatter dateFormat =
DateTimeFormat.forPattern("'Fiscal Week 'ww");

        String week = dateFormat.print(dateTime);

This returns "Fiscal Week 01'. Would there be a way to prevent it from
doing a conversion ?

Thanks again for your help



On Thu, Jul 29, 2010 at 1:36 PM, Stephen Colebourne
<[email protected]> wrote:
> I believe that you do the following, although I've never used the feature!
>
>  Chronology lenient =
> LenientChronology.getInstance(ISOChronology.getInstance());
>  formatter = formatter.withChronology(chrono);
>  // continue parsing as normal
>
> Stephen
>
>
> On 29 July 2010 19:24, Robin Tharappel <[email protected]> wrote:
>> Hello,
>>
>> I was looking for an example of configuring a Joda parser to be more
>> lenient when parsing a value or an example of changing the range of
>> acceptable values for a field. For example if I have the following
>> value for a fiscal week (format yyyy'W'ww) representing a 54 week.
>>
>>
>> DateTimeFormatter formatter = DateTimeFormat.forPattern("yyyy'W'ww");
>> DateTime dateTime = formatter.parseDateTime("2009W54");
>>
>> This would throw an exception:
>>
>> Cannot parse "2009W54": Value 54 for weekOfWeekyear must be in the range 
>> [1,52]
>>
>> There appear to be support specifying a field as lenient
>>
>> http://joda-time.sourceforge.net/api-release/org/joda/time/field/LenientDateTimeField.html
>>
>> How would you configure the DateTimeFormatter to have a lenient field ?
>>
>> Thanks
>>
>> ------------------------------------------------------------------------------
>> The Palm PDK Hot Apps Program offers developers who use the
>> Plug-In Development Kit to bring their C/C++ apps to Palm for a share
>> of $1 Million in cash or HP Products. Visit us here for more details:
>> http://p.sf.net/sfu/dev2dev-palm
>> _______________________________________________
>> Joda-interest mailing list
>> [email protected]
>> https://lists.sourceforge.net/lists/listinfo/joda-interest
>>
>
> ------------------------------------------------------------------------------
> The Palm PDK Hot Apps Program offers developers who use the
> Plug-In Development Kit to bring their C/C++ apps to Palm for a share
> of $1 Million in cash or HP Products. Visit us here for more details:
> http://p.sf.net/sfu/dev2dev-palm
> _______________________________________________
> Joda-interest mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/joda-interest
>

------------------------------------------------------------------------------
The Palm PDK Hot Apps Program offers developers who use the
Plug-In Development Kit to bring their C/C++ apps to Palm for a share
of $1 Million in cash or HP Products. Visit us here for more details:
http://p.sf.net/sfu/dev2dev-palm
_______________________________________________
Joda-interest mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/joda-interest

Reply via email to