How to add hours, minutes, seconds into DateTime in Joda Time?

In this example you’ll learn how to add some hours, minutes or seconds into the DateTime object in Joda Time. Some couple methods available to plus or minus some hours, minutes or seconds from the object, as you can see in the example below.

The DateTime object is an immutable object, which means calling one of the plus or minus method does not modified the current object. Instead, these method return a new DateTime object for each method calls.

The program print the following result:

How do I use Joda Time Instant Class?

An instant in the datetime continuum specified as a number of milliseconds from 1970-01-01T00:00Z. Some classes that represent an instance in the Joda Time library includes the Instant, DateTime, DateMidnight and MutableDateTime classes.

Here is the result of our program:

How do I use the Interval class of Joda Time?

This example show you how to use the org.joda.time.Interval class in Joda. An interval object represent an interval of time from one millisecond instant to another instant.

Below is the result printed by our program: