- package Mych1;
- import java.text.*;
- public class StringMe
- {
- public static void main(String[]args)
- {
- //System.out.println(new Time(12,33,45).toString());
- System.out.println(new Time(13,33,45).show());
- }
- }
- class Time
- {
- public int hour;
- public int minute;
- public int seconds;
- public Time(int hour,int minute,int seconds)
- {
- this.hour=hour;
- this.minute=minute;
- this.seconds=seconds;
- }
- public String show()
- {
- DecimalFormat df=new DecimalFormat("00");//这个00是干什么的啊,看API没看明白,这个参数
- String str=df.format(hour%12)+":"+df.format(minute)+":"+df.format(seconds);
- return str;
- }
- }
复制代码 求助这个java.text.DecimalFormat的用法,真心有点没看懂,那个00是什么意思。上面代码输出的结果是:01:33:45,如果是DecimalFormat df=new DecimalFormat("11");就变成了111:1133:1145,我瞬间迷茫了。。。这是什么原理啊 |