⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 e326. formatting a message containing a date.txt

📁 这里面包含了一百多个JAVA源文件
💻 TXT
字号:
Object[] params = new Object[]{new Date(), new Date(0)};
    String msg = MessageFormat.format("Today is {0} and UTC of 0 is {1}", params);
    // Today is 2/27/02 2:00 PM and UTC of 0 is 12/31/69 4:00 PM
    
    msg = MessageFormat.format("Today is {0,date} and UTC of 0 is {1,date}", params);
    // Today is Feb 27, 2002 and UTC of 0 is Dec 31, 1969
    
    msg = MessageFormat.format("Today is {0,date,short} and UTC of 0 is {1,date,short}", params);
    // Today is 2/27/02 and UTC of 0 is 12/31/69
    
    msg = MessageFormat.format("Today is {0,date,medium} and UTC of 0 is {1,date,medium}", params);
    // Today is Feb 27, 2002 and UTC of 0 is Dec 31, 1969
    
    msg = MessageFormat.format("Today is {0,date,long} and UTC of 0 is {1,date,long}", params);
    // Today is February 27, 2002 and UTC of 0 is December 31, 1969
    
    msg = MessageFormat.format("Today is {0,date,full} and UTC of 0 is {1,date,full}", params);
    // Today is Wednesday, February 27, 2002 and UTC of 0 is Wednesday, December 31, 1969
    
    // Use a custom format; see e320 Formatting a Date Using a Custom Format
    msg = MessageFormat.format("Today is {0,date,MMM d} and UTC of 0 is {1,date,MMM d}", params);
    // Today is Feb 27 and UTC of 0 is Dec 31

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -