Opposite of subtracting hours from a java date, this example will demonstrates how to add hours to date using Calendar.add, java 8 date time api, joda LocalDateTime.plusHours and apache commons DateUtils.addHours. In the examples below, we will set a date that represents new years eve, December 31st, then adding one hour to return a date representing new years day or January 1st.
Straight up Java
Output
Java 8 Date and Time API
Java 8 LocalDateTime.plusHours will return a copy of the LocalDateTime with the specified number of hours added.
Output
Joda Time
Joda DateTime.plusHours will return a copy the DateTime plus the specified number of hours.
Output
Apache Commons
Apache commons DateUtils.addHours will add a number of hours to the date returning a new object.