import org.junit.Test; public class TestMe { @Test public void test() throws IOException { // 占位符指定使用哪个参数填充值 System.out.printf("%2$s %2$s %1$s \n", "111", "222"); // 111 111 222 // 浮点数保留小数点后尾数(四舍五入取整) System.out.printf("%.2f \n", 1.256F); // 1.23 // 千分位分割输出整型 System.out.printf("%,d \n", 12345678); // 12,345,678 // 默认右对齐 System.out.printf("%12d| %15d| \n", 12345678, 666666666); // 左对齐,不足补空格 System.out.printf("%-12d| %-15d| \n", 12345678, 666666666); System.out.println(); // '%%'输出百分号%% System.out.printf("%d%% \n", 58); // 不足位补零 System.out.printf("%05d \n", 98); // 00058 // 负数将添加括号 System.out.printf("%(d \n", -98); // (98) System.out.printf("%tF \n", System.currentTimeMillis()); // 14:28:07 System.out.printf("%tT \n", System.currentTimeMillis()); // 2013-08-15 } }
参考:http://java.chinaitlab.com/base/835591.html
--end
相关推荐
printf格式
C语言中printf格式详细介绍了该函数的使用方式,希望对大家有帮助
c语言printf格式控制符,c语言printf格式控制符,c语言printf格式控制符
printf格式控制符的完整格式,网上看到的帖子,保存为txt了
C语言Printf格式详解 C语言Printf格式详解
S32K144在FreeRTOS下使用printf格式化输出,不依赖与本地库文件,可直接编译通过
输入输出函数(printf 和 scanf)是C语言中非常重要的两个函数,也是学习C语言必学的两个函数。在C语言程序中,几乎没有一个程序不需要这两个函数,尤其是输出函数(printf),所以这两个函数必须要掌握。 如果在...
必须用与数据类型相匹配的输出格式,才能把数据...C语言的printf函数提供了丰富的输出格式,printf的格式控制的完整格式由前导字符与格式字符构成,即: %前导字符格式字符 其中%:表示格式说明的起始符号,不可缺少。
经典的C语言下,打印屏幕函数printf输出格式总结,当然在VC下也可借鉴
stm32f103的串口123的dma配置,dma方式可以节约cpu资源,并且3个串口支持同时运行,3个串口都支持printf格式发数据。
printf输出格式 格式代码 A ABC ABCDEFGH %S A ABC ABCDEFGH %5S ####A ##ABC ABCDEFGH %.5S A ABC ABCDE %5.5S ####A ##ABC ABCDE % - 5S A#### ABC## ABCDEFGH
c语言常用到的printf输出格式汇总。printf函数称为格式输出函数,其关键字最末一个字母f即为“格式”(format)之意。其功能是按用户指定的格式,把指定的数据显示到显示器屏幕上。
C 类型安全Python风格的Printf格式
C语言中printf格式.doc
STM32绑定printf格式输出的文档说明,
c语言printf()输出格式大全,希望对大家有帮助
关于 printf格式输出 打印各个格式规范 scanf输入语句规范
详解Java中print、printf、println的区别 很实用
ACM 第06课-printf格式.pdf