I am using the below code snippet. When I am using 201230, the year being returned is 2020. If I input 301230, it gives 1930. I am expecting 1920 similarly for 201230 input also. Can some one please clarify, what I need to do to ensure I get 1920 instead of 2020? Also, the other issue, is how does java know whether it is a future date input or input of past date?
For parsing with the abbreviated year pattern ("y" or "yy"), SimpleDateFormat must interpret the abbreviated year relative to some century. It does this by adjusting dates to be within 80 years before and 20 years after the time the SimpleDateFormat instance is created.
So for "30" to parse as "2030", just wait about three weeks! More generally, if you want the year to always be parsed as this century, you might want to insert a "20".