Java Date setHours() MethodLast Updated : 17 Mar 2025 The setHours() method of Java Date class sets hour of the day of this date object to represent new value of date object. It changes the previous hour of the day value to the new specified value. This method is deprecated as of JDK version 1.1 and replaced by Calendar.set(Calendar.HOUR_OF_DAY, int hours). Syntax:ParametersThe parameter 'hours' represents the hour value between 0-23. ReturnNA Example 1Output: Old hour value is : 8 Hour value after setting is : 10 Next TopicJava Util Date |
We request you to subscribe our newsletter for upcoming updates.

We deliver comprehensive tutorials, interview question-answers, MCQs, study materials on leading programming languages and web technologies like Data Science, MEAN/MERN full stack development, Python, Java, C++, C, HTML, React, Angular, PHP and much more to support your learning and career growth.
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India