public class Mytest { public static void main(String[] args) { System.out.println(String.format("[ PASS ] %s : 耗时: %s 毫秒", 1, "1111")); } }
输入结果:
[ PASS ] 1 : 耗时: 1111 毫秒
转 换 符 | 说 明 |
%s | 字符串类型 |
%c | 字符类型 |
%b | 布尔类型 |
%d | 整数类型(十进制) |
%x | 整数类型(十六进制) |
%f | 浮点类型 |
%o | 整数类型(八进制) |
%a | 十六进制浮点类型 |
%e | 指数类型 |
%g | 通用浮点类型(f和e类型中较短的) |
%h | 散列码 |
%% | 百分比类型 |
%tx | 日期与时间类型(x代表不同的日期与时间转换符 |
%n | 换行符 |