String.format 日期格式处理

/*

   获取系统当前日志 date 转 字符串

   %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);

    }

输出格式:2017-03-28 14:50:19

猜你喜欢

转载自no-zuo-no-die2016.iteye.com/blog/2366260