Java中的格式化输出 printf 与 println

package javacore;

import java.util.Date;

/**
 * @author lixw
 * @date created in 15:41 2018/12/16
 */
public class FormatTest {
    public static void main(String[] args) {
        double x = 10000.0/3.0;
        System.out.printf("8.2%f",x);
        System.out.println();
        System.out.printf("%,.2f",1000.0/3.0);
        System.out.println();
        System.out.printf("%Tp",new Date());
        System.out.println();
        System.out.println(new Date());
    }
}

在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/qq_42664961/article/details/85037842
今日推荐