-
1. Re: Converting date correctly from YY to YYYY
kragoth Jun 26, 2011 7:00 PM (in response to cash1981)From a pure mathematical/java/date perspective 01.01.11 is CORRECTLY translated to 01.01.0011. That is the absolute correct result. What if the application is being written for a history tool. How would they enter the year 11 AD if 11 was always translated to 2011. How do you know exactly what century 11 is in? Should that date be 2011, 1911, 1811? Every century is valid. Thus the only way to correctly convert 01.01.11 to a date is to represent it exactly - the year 11 AD.
Now, how do you fix it. Quite simple really. Write your own converter. In your converter you will need to decide at what point does a 2 digit year convert from a 21st century year to a 20th century year. Does 01.01.99 mean 2099 or does it mean 1999. You'll need to write this yourself.
Java is doing the right thing. It has no way of knowing what century a 2 digit year belongs in so... you'll have to tell it.
-
2. Re: Converting date correctly from YY to YYYY
cash1981 Jun 27, 2011 3:36 AM (in response to cash1981)Hi Tim.
Thanks for the answer. I guess it makes sense when you put it like that.