Javatpoint Logo
Javatpoint Logo

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

Test it Now

Output:

Old hour value is : 8
Hour value after setting is : 10

Next TopicJava Util Date





Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA