hh and HH issues related to SimpleDateFormat in Data

Insert image description here

Date dNow = new Date( );
        SimpleDateFormat ft1 = new SimpleDateFormat ("yyyy-MM-dd hh:mm:ss");//hh是12小时制;
        SimpleDateFormat ft2 = new SimpleDateFormat ("yyyy-MM-dd HH:mm:ss");//HH是24小时制;
        System.out.println("当前时间为:"+ft1.format(dNow));
        System.out.println("当前时间为:"+ft2.format(new Date()));

The output is:

当前时间为:2023-03-21 04:09:25
当前时间为:2023-03-21 16:09:25
  • This line of code establishes the format of the conversion, where yyyy is the complete AD year, MM is the month, dd is the date, and HH:mm:ss is the hour, minute, and second.
    Note: Some formats are uppercase, and some are lowercase. For example, MM is the month, mm is the minute; HH is the 24-hour format, and hh is the 12-hour format.

Guess you like

Origin blog.csdn.net/budaoweng0609/article/details/129691174
.hh
hh