Y returns 2012 while y returns 2011 in SimpleDateFormat

前端 未结 5 993
粉色の甜心
粉色の甜心 2020-11-22 01:39

I wonder why \'Y\' returns 2012 while \'y\' returns 2011 in SimpleDateFormat:

System.out.println(new SimpleDateFormat(\"Y\").format(new Date()))         


        
5条回答
  •  灰色年华
    2020-11-22 02:38

    I learned the hard way the JSTL tag library format:date with short as the requested format uses YYYY under the covers. Which can indeed roll the printed date ahead a year.

提交回复
热议问题