/** * Creates a local time from the hour, minute, second and nanosecond fields. * <p> * This factory may return a cached value, but applications must not rely on this. * * @param hour the hour-of-day to represent, validated from 0 to 23 * @param minute the minute-of-hour to represent, validated from 0 to 59 * @param second the second-of-minute to represent, validated from 0 to 59 * @param nanoOfSecond the nano-of-second to represent, validated from 0 to 999,999,999 * @return the local time, not null */ private static LocalTime create(int hour, int minute, int second, int nanoOfSecond) { if ((minute | second | nanoOfSecond) == 0) { return HOURS[hour]; } return new LocalTime(hour, minute, second, nanoOfSecond); }
/** * Creates a local time from the hour, minute, second and nanosecond fields. * <p> * This factory may return a cached value, but applications must not rely on this. * * @param hour the hour-of-day to represent, validated from 0 to 23 * @param minute the minute-of-hour to represent, validated from 0 to 59 * @param second the second-of-minute to represent, validated from 0 to 59 * @param nanoOfSecond the nano-of-second to represent, validated from 0 to 999,999,999 * @return the local time, not null */ private static LocalTime create(int hour, int minute, int second, int nanoOfSecond) { if ((minute | second | nanoOfSecond) == 0) { return HOURS[hour]; } return new LocalTime(hour, minute, second, nanoOfSecond); }
/** * Obtains an instance of {@code LocalTime} from an hour and minute. * <p> * The second and nanosecond fields will be set to zero by this factory method. * <p> * This factory may return a cached value, but applications must not rely on this. * * @param hour the hour-of-day to represent, from 0 to 23 * @param minute the minute-of-hour to represent, from 0 to 59 * @return the local time, not null * @throws DateTimeException if the value of any field is out of range */ public static LocalTime of(int hour, int minute) { HOUR_OF_DAY.checkValidValue(hour); if (minute == 0) { return HOURS[hour]; // for performance } MINUTE_OF_HOUR.checkValidValue(minute); return new LocalTime(hour, minute, 0, 0); }
/** * Obtains an instance of {@code LocalTime} from an hour and minute. * <p> * The second and nanosecond fields will be set to zero by this factory method. * <p> * This factory may return a cached value, but applications must not rely on this. * * @param hour the hour-of-day to represent, from 0 to 23 * @param minute the minute-of-hour to represent, from 0 to 59 * @return the local time, not null * @throws DateTimeException if the value of any field is out of range */ public static LocalTime of(int hour, int minute) { HOUR_OF_DAY.checkValidValue(hour); if (minute == 0) { return HOURS[hour]; // for performance } MINUTE_OF_HOUR.checkValidValue(minute); return new LocalTime(hour, minute, 0, 0); }
/** * Obtains an instance of {@code LocalTime} from an hour, minute and second. * <p> * The nanosecond field will be set to zero by this factory method. * <p> * This factory may return a cached value, but applications must not rely on this. * * @param hour the hour-of-day to represent, from 0 to 23 * @param minute the minute-of-hour to represent, from 0 to 59 * @param second the second-of-minute to represent, from 0 to 59 * @return the local time, not null * @throws DateTimeException if the value of any field is out of range */ public static LocalTime of(int hour, int minute, int second) { HOUR_OF_DAY.checkValidValue(hour); if ((minute | second) == 0) { return HOURS[hour]; // for performance } MINUTE_OF_HOUR.checkValidValue(minute); SECOND_OF_MINUTE.checkValidValue(second); return new LocalTime(hour, minute, second, 0); }
/** * Obtains an instance of {@code LocalTime} from an hour, minute and second. * <p> * The nanosecond field will be set to zero by this factory method. * <p> * This factory may return a cached value, but applications must not rely on this. * * @param hour the hour-of-day to represent, from 0 to 23 * @param minute the minute-of-hour to represent, from 0 to 59 * @param second the second-of-minute to represent, from 0 to 59 * @return the local time, not null * @throws DateTimeException if the value of any field is out of range */ public static LocalTime of(int hour, int minute, int second) { HOUR_OF_DAY.checkValidValue(hour); if ((minute | second) == 0) { return HOURS[hour]; // for performance } MINUTE_OF_HOUR.checkValidValue(minute); SECOND_OF_MINUTE.checkValidValue(second); return new LocalTime(hour, minute, second, 0); }