98
Java Date setHours() Method
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:
Parameters
The parameter ‘hours’ represents the hour value between 0-23.
Return
NA
Example 1
Output:
Old hour value is : 8 Hour value after setting is : 10
Next TopicJava Util Date