JodaTime Duration

Overview

Duration specifies a length of time in milliseconds. Refer to
Duration
on Joda-Time site for further details.

  1. Create Duration
  2. Perform Arithmetic Operations On Duration
  3. Convert Duration To Single Fields Periods like Days, Hours, Minutes and Seconds

Create Duration

Duration can be created using the following ways:

  1. Using two DateTime instances
  2. Using Millis
  3. From Days
  4. From Hours
  5. From Minutes

The output is shown in
ISO8601 format
.


Perform Arithmetic Operations On Duration

As of Joda-Time 2.3, The following arithmetic operations are supported:

  1. Addition: Adding millis to a duration
  2. Repeated Addition: Addition millis to a duration repeated for a certain number of times
  3. Subtraction: Subtracting millies from a duration

The output is shown in
ISO8601 format
.


Convert Duration To Single Fields Periods like Days, Hours, Minutes and Seconds

The output is shown in
ISO8601 format
.


To start, click on the next arrow. If you find anything missing in the tutorials then please drop in your comments.

Leave a Reply

Your email address will not be published. Required fields are marked *