【Java】字符串补零

    public static void main(String[] args) {
        int h = 5;
        int m = 45;
        int s = 2;
        int ms = 67;
        // 补零
        System.out.println(String.format("%02d:%02d:%02d,%03d", h, m, s, ms)); // 05:45:02,067
    }

 

posted @ 2022-04-03 10:47  淡怀  阅读(464)  评论(0编辑  收藏  举报