Java程序以大写形式显示日期和时间信息
首先,创建一个格式化程序和一个Calendar对象。
Formatter f = new Formatter(); Calendar c = Calendar.getInstance();
要显示完整的日期和时间信息,请使用'c'转换字符。但是,要以大写形式显示,请使用“Tc”。
f = new Formatter();
System.out.println(f.format("\nDate and Time (uppercase): %Tc\n", cal));以下是一个例子-
示例
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("\nDate and Time (uppercase): %Tc\n", cal));
}
}输出结果
Current date and time: Mon Nov 26 07:44:39 UTC 2018 Date and Time (lowercase): MON NOV 26 07:44:39 UTC 2018
热门推荐
5 短祝福语简短暖心
10 结婚祝福语粤语大全简短
11 晚上祝福语女生文案简短
12 法语妈妈生日祝福语简短
13 药厂开工祝福语大全简短
14 蛋糕节日祝福语简短英文
15 跨年的生日祝福语简短
16 文案祝福语英文短句简短
17 在家聚餐婚礼祝福语简短
18 学生节祝福语大全简短