Question about ISODateTimeFormat strictness

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

Question about ISODateTimeFormat strictness

Alexander Reelsen
Hey there,

I just now discovered, theĀ dateElementParser in ISODateTimeFormat allows for years, which are not composed of at least four digits. I do not have access to the ISO standard, but reading wikipedia (which might not be right) states:

ISO 8601 prescribes, as a minimum, a four-digit year [YYYY] to avoid the year 2000 problem.

Still, you can get a number like '5' parsed as a valid year.

Likely being wildly wrong here, but I guess this is supposed to work like that? Is there an option to make it more strict and force people to write 0005 or am I better off implementing that myself?

Thanks for any help and hints!


--Alex

------------------------------------------------------------------------------
"Accelerate Dev Cycles with Automated Cross-Browser Testing - For FREE
Instantly run your Selenium tests across 300+ browser/OS combos.
Get unparalleled scalability from the best Selenium testing platform available
Simple to use. Nothing to install. Get started now for free."
http://p.sf.net/sfu/SauceLabs
_______________________________________________
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: Question about ISODateTimeFormat strictness

jodastephen
You can use DateTimeFormatterBuilder and control the min/max digits:
http://joda-time.sourceforge.net/apidocs/org/joda/time/format/DateTimeFormatterBuilder.html#appendYear%28int,%20int%29
Stephen

On 16 May 2014 09:51, Alexander Reelsen <[hidden email]> wrote:

> Hey there,
>
> I just now discovered, the dateElementParser in ISODateTimeFormat allows for
> years, which are not composed of at least four digits. I do not have access
> to the ISO standard, but reading wikipedia (which might not be right)
> states:
>
> ISO 8601 prescribes, as a minimum, a four-digit year [YYYY] to avoid the
> year 2000 problem.
>
> Still, you can get a number like '5' parsed as a valid year.
>
> Likely being wildly wrong here, but I guess this is supposed to work like
> that? Is there an option to make it more strict and force people to write
> 0005 or am I better off implementing that myself?
>
> Thanks for any help and hints!
>
>
> --Alex
>
> ------------------------------------------------------------------------------
> "Accelerate Dev Cycles with Automated Cross-Browser Testing - For FREE
> Instantly run your Selenium tests across 300+ browser/OS combos.
> Get unparalleled scalability from the best Selenium testing platform
> available
> Simple to use. Nothing to install. Get started now for free."
> http://p.sf.net/sfu/SauceLabs
> _______________________________________________
> Joda-interest mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/joda-interest
>

------------------------------------------------------------------------------
"Accelerate Dev Cycles with Automated Cross-Browser Testing - For FREE
Instantly run your Selenium tests across 300+ browser/OS combos.
Get unparalleled scalability from the best Selenium testing platform available
Simple to use. Nothing to install. Get started now for free."
http://p.sf.net/sfu/SauceLabs
_______________________________________________
Joda-interest mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/joda-interest
Loading...