Java Minute Validate validateHoursAndMinutes(int hours, int minutes)

Here you can find the source of validateHoursAndMinutes(int hours, int minutes)

Description

Checks that hour and minutes within conventional 24 hour clock bounds.

License

Open Source License

Parameter

Parameter Description
hours - 0 to 23
minutes - 0 to 59

Exception

Parameter Description
NumberFormatException if digital time format invalid

Declaration

protected static void validateHoursAndMinutes(int hours, int minutes) throws NumberFormatException 

Method Source Code

//package com.java2s;

public class Main {
    /**//from w  w  w .  j a  v a2  s .c o m
     * Checks that hour and minutes within conventional 24 hour clock bounds.
     * 
     * @param hours - 0 to 23
     * @param minutes - 0 to 59
     * @throws NumberFormatException if digital time format invalid
     * */
    protected static void validateHoursAndMinutes(int hours, int minutes) throws NumberFormatException {
        if ((minutes >= 60 || minutes < 0) || (hours >= 24 || hours < 0)) {
            throw new NumberFormatException();
        }
    }
}

Related

  1. validateMinute(int minute)
  2. valueOfMinute(long time)