Why does Java's Date.getYear() return 111 instead of 2011?

后端 未结 6 2023
抹茶落季
抹茶落季 2020-11-28 09:25

I am having a bit of trouble parsing a string date to a Date object. I use a DateFormat to parse the string, and when I print the value of the date

6条回答
  •  囚心锁ツ
    2020-11-28 09:39

    http://download.oracle.com/javase/1.4.2/docs/api/java/util/Date.html#getYear%28%29

    The specification states that it returns the year minus 1900. Probably a good idea to avoid deprecated methods as well.

提交回复
热议问题