📄 main.java
字号:
import java.util.*;
class Main {
public static void main(String[] args) {
Calendar cal = Calendar.getInstance();
cal.setTimeZone(TimeZone.getTimeZone("GMT"));
// Is midnight am or pm?
cal.setTime(new Date(0));
System.out.println(cal.get(Calendar.AM_PM)); // 0 <AM>
// A millisecond before midnight?
cal.setTime(new Date(-1));
System.out.println(cal.get(Calendar.AM_PM)); // 1 <PM>
// How about noon?
cal.setTime(new Date(12*60*60*1000));
System.out.println(cal.get(Calendar.AM_PM)); // 1 <PM>
// Add 12 hours to the current time.
cal = Calendar.getInstance();
System.out.println(cal.get(Calendar.AM_PM)); // 0 <AM>
cal.add(Calendar.HOUR, 12);
System.out.println(cal.get(Calendar.AM_PM)); // 1 <PM>
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -