You are misusing the week field, thus it doesn't work as you want. The week field is defined as following the ISO-8601 rules, at least within the context of the ISO chronology. As such, the values go from 1 to 52/53.
If you want a field with different rules, you need to write your own DateTimeField, which will require its own Chronology to host it. This is a complex task, with no real javadoc to help (although a lot of code can be reused). I suspect you'll find it easier to code around the problem rather than creating a new field. Stephen On 29 July 2010 21:26, Robin Tharappel <rtharap...@gmail.com> wrote: > 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 > <scolebou...@joda.org> 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 <rtharap...@gmail.com> 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 >>> Joda-interest@lists.sourceforge.net >>> 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 >> Joda-interest@lists.sourceforge.net >> 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 > Joda-interest@lists.sourceforge.net > 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 Joda-interest@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/joda-interest