标签:ati ack sys jdk pac 保留 lte span ima
package cn.time; import java.text.DecimalFormat; public class JdkUtilTest { public static void main(String[] args) { DecimalFormat df = new DecimalFormat("#0.0"); //保留2位,不足补0 DecimalFormat df_fill_zero = new DecimalFormat("00.00"); //保留2位,不足保留原位数 DecimalFormat df_fill_null = new DecimalFormat("##.##"); System.out.println(df_fill_zero.format(1.2)); //01.20 不足2位补0 System.out.println(df_fill_null.format(1.2)); //1.2 不足2位保留原数位 System.out.println( df.format(1.2)); System.out.println(df_fill_zero.format(1.224)); //01.22 超出2位截断(舍入模式后面再说) System.out.println(df_fill_null.format(1.224)); //1.22 超出2位截断(舍入模式后面再说) System.out.println( df.format(1.224)); System.out.println(df_fill_zero.format(123.22)); //123.22 System.out.println(df_fill_null.format(123.22)); //123.22 System.out.println( df.format(123.22)); } }
标签:ati ack sys jdk pac 保留 lte span ima
原文地址:https://www.cnblogs.com/smileblogs/p/12447967.html