How do I add n hours to a Date object? I found another example using days on StackOverflow, but still don't understand how to do it with hours.
相关问题
- Delete Messages from a Topic in Apache Kafka
- Jackson Deserialization not calling deserialize on
- How to maintain order of key-value in DataFrame sa
- StackExchange API - Deserialize Date in JSON Respo
- Difference between Types.INTEGER and Types.NULL in
You can do it with Joda DateTime API
by using Java 8 classes. we can manipulate date and time very easily as below.
Since Java 8:
See
LocalDateTime
API.You can use this method, It is easy to understand and implement :
With Joda-Time
Check Calendar class. It has
add
method (and some others) to allow time manipulation. Something like this should work.Check API for more.