I've got a ticket around this (
https://sourceforge.net/p/awsversionmgmt/tickets/8/ ) as well as a wiki page
(https://sourceforge.net/p/awsversionmgmt/wiki/DateFormatsSupportedInCommand
Line/ ) as this is a tricky one on my side and as such looking for
suggestions and ideas.
The problem is that due to the usage of the class SimpleDateFormat (part of
the JDK), both of these dates are considered as valid (bear in mind format
is yyyy-mm-dd):
2013-01-01 (jan/1/2013)
As well as
2013-13-01 (which gets interpreted as 2014/jan/01)
Trouble is that 2013-156-01 gets accepted as well (156 = 13 * 12 and as such
it gets interpreted as 2013+13 = 2016/01/01). Not to mention that also
2999999-01-01 is valid too!
However, really we shouldn't allow for these dates to be accepted as valid
dates. Currently the code uses some validation via regular expressions to
ensure the year has 4 digits, month has 2, day has 2 etc. While this will
discard 2013-156-01 and 29999999-01-01, it won't "catch" 2013-13-01 even
though 13 is not a valid date :(
So how can we go about ensuring a proper date format? One idea is to tighten
up the regular expression such that it only allows months up to 12 etc, but
is there a better way around it?
Liv
Liviu Tudor
E: liv...@gm... <mailto:liv...@gm...>
C: +1 650-2833815 (USA)
M: +44 (0)7591540313 (UK, Europe)
W: http://about.me/liviutudor <http://about.me/liviutudor>
Skype: liviutudor
I'm nobody, nobody's perfect -- therefore I'm perfect!
|