Date date = new Date(); // given date
Calendar calendar = GregorianCalendar.getInstance(); // creates a new calendar instance
calendar.setTime(date); // assigns calendar to given date
calendar.get(Calendar.HOUR_OF_DAY); // gets hour in 24h format
calendar.get(Calendar.HOUR); // gets hour in 12h format
calendar.get(Calendar.MONTH); // gets month number, NOTE this is zero based!
int hour = zdt.getHour() ;
int minute = zdt.getMinute() ;
LocalTime
如果你想只是一天的时间没有时区,提取 LocalTime。
LocalTime lt = zdt.toLocalTime() ;
或者完全跳过 ZonedDateTime,直接跳到 LocalTime。
LocalTime lt = LocalTime.now( z ) ; // Capture the current time-of-day as seen in the wall-clock time used by the people of a particular region (a time zone).