java - 新手求教,当前时间问题?
巴扎黑
巴扎黑 2017-04-18 10:51:47
0
3
549

代码如下:

SimpleDateFormat std = new SimpleDateFormat("yyyy-mm-dd hh:mm:ss"); System.out.println(std.format(new Date()));

为什么输出之后是2017-11-24 10:11:28, 2017-13-24 10:13:27.....等等之类的,好奇怪

每运行一次加一个月

完整代码:

巴扎黑
巴扎黑

reply all (3)
刘奇

yyyy-mm-dd is changed to yyyy-MM-dd, which is capital letters!!! Capital letters indicate the month!!!

    PHPzhong

    yyyy is the complete Western Year, MM (capital) is the month, and dd is the date. As for hh:mm:ss, why are some formats uppercase and some lowercase? That’s to avoid confusion. For example, MM is the month and mm is the date. Minutes; HH is a 24-hour clock, and hh is a 12-hour clock

      PHPzhong

      The lowercase m represents minutes, so it will change every minute, just change it to an uppercase M

        Latest Downloads
        More>
        Web Effects
        Website Source Code
        Website Materials
        Front End Template
        About us Disclaimer Sitemap
        php.cn:Public welfare online PHP training,Help PHP learners grow quickly!