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 format date in Joda using ISODateTimeFormat class?

This example demonstrate how to use the ISODateTimeFormat class to format the date time information in Joda.

The result of the code above is printed below:

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: