在Java中按名称和数字显示月份
在Java中,将“b”转换字符用作月份名称。
在Java中,将'm'转换字符用作月份号。
在这里,我们使用Formatter和Calendar类,因此导入以下包。
import java.util.Calendar; import java.util.Formatter;
以下是显示月份名称和数字的示例-
示例
import java.util.Calendar;
import java.util.Formatter;
public class Demo {
public static void main(String args[]) {
Formatter f = new Formatter();
Calendar cal = Calendar.getInstance();
System.out.println("Current date and time: "+cal.getTime());
f = new Formatter();
System.out.println(f.format("Month = %tb \nMonth Number = %tm", cal, cal));
}
}输出结果
Current date and time: Mon Nov 26 07:07:31 UTC 2018 Month = Nov Month Number = 11
热门推荐
1 训练狗狗工作
4 狗狗定点排便训练
5 狗狗训练吠叫
6 狗狗尿垫训练
7 狗狗训练座
8 狗狗训练攻略
9 狗狗训练记
10 做训练狗狗
11 狗狗训练词
12 狗狗谢谢怎么训练
13 狗狗训练如厕
14 狗狗太凶怎么训练
15 狗狗训练它
16 狗狗克制训练
17 训练基地狗狗
18 怎么样训练狗狗大小硬