📄 e325. formatting a message containing a time.txt
字号:
Object[] params = new Object[]{new Date(), new Date(0)};
String msg = MessageFormat.format("The time is {0} and UTC of 0 is {1}", params);
// The time is 2/27/02 2:08 PM and UTC of 0 is 12/31/69 4:00 PM
msg = MessageFormat.format("The time is {0,time} and UTC of 0 is {1,time}", params);
// The time is 2:08:48 PM and UTC of 0 is 4:00:00 PM
msg = MessageFormat.format("The time is {0,time,short} and UTC of 0 is {1,time,short}", params);
// The time is 2:08 PM and UTC of 0 is 4:00 PM
msg = MessageFormat.format("The time is {0,time,medium} and UTC of 0 is {1,time,medium}", params);
// The time is 2:08:48 PM and UTC of 0 is 4:00:00 PM
msg = MessageFormat.format("The time is {0,time,long} and UTC of 0 is {1,time,long}", params);
// The time is 2:08:48 PM PST and UTC of 0 is 4:00:00 PM PST
msg = MessageFormat.format("The time is {0,time,full} and UTC of 0 is {1,time,full}", params);
// The time is 2:08:48 PM PST and UTC of 0 is 4:00:00 PM PST
// Use a custom format; see e316 Formatting the Time Using a Custom Format
msg = MessageFormat.format("The time is {0,time,HH-mm-ss} and UTC of 0 is {1,time,HH-mm-ss}", params);
// The time is 14-11-41 and UTC of 0 is 16-00-00
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -