Java 获取当前小时

Calendar calendar = Calendar.getInstance();
int hour = calendar.get(Calendar.HOUR_OF_DAY); // 24小时制

Calendar calendar = Calendar.getInstance();
int hour = calendar.get(Calendar.HOUR); // 12小时制

 

posted on 2021-03-03 10:21  xiaofei01gm  阅读(7957)  评论(0编辑  收藏  举报