Java程序以小写形式显示日期和时间信息
首先,创建一个Formatter和一个Calendar对象。
Formatter f = new Formatter(); Calendar c = Calendar.getInstance();
要显示完整的日期和时间信息,请使用'c'转换字符。但是,要以小写形式显示,请使用'tc'-
f = new Formatter();
System.out.println(f.format("\nDate and Time (lowercase): %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 (lowercase): %tc\n", cal));
}
}输出结果
Current date and time: Mon Nov 26 07:43:47 UTC 2018 Date and Time (lowercase): Mon Nov 26 07:43:47 UTC 2018
热门推荐
10 新人给朋友祝福语简短
11 生日祝福语大全简短霸气
12 同事除夕加班祝福语简短
13 送情侣生日祝福语简短
14 立秋对母亲祝福语简短
15 喜欢新车的祝福语简短
16 朋友搞笑蛋糕祝福语简短
17 优秀男士祝福语大全简短
18 学院祝福语女生大全简短