String.format date format processing

/*

   Get the current log date of the system and convert it to a string

   %tf  2017-03-28

   %tT  14:50:19

   %tR  14:50

    */

    public static void main(String[] args){

        Date date = new Date();

        String str = String.format("%tF", date) + " " + String.format("%tT", date);

        System.out.println(str);

    }

 

Output format: 2017-03-28 14:50:19

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326831174&siteId=291194637