转载:https://blog.csdn.net/iamzhangyouzhi/article/details/38542401
方法一:
Date date = new Date(); int hours = date.getHours();
方法二:
GregorianCalendar calendar = new GregorianCalendar(); int hour = calendar.get(Calendar.HOUR_OF_DAY); System.out.println("hour=" + hour);