public class Duration extends Object
This class describes a duration as defined by ISO 8601.
Modifier and Type | Method | Description |
---|---|---|
Duration |
add(Duration d) |
|
int |
amount(Unit unit) |
|
void |
back(Calendar cal) |
|
static Duration |
create(int amount,
Unit unit) |
|
boolean |
equals(Object o) |
True if the argument is a duration with the same or equivalent specification.
|
void |
forward(Calendar cal) |
|
static Duration |
fromMillis(long millis) |
|
int |
hashCode() |
|
void |
next(Calendar cal) |
Moves the calendar to the next position, as if divided into pieces of time with the length defines by this Duration.
|
static Duration |
parse(String input) |
Parses a duration.
|
Unit |
precision() |
|
long |
toDays() |
Calculated as if it was an interval from 1 Jan 1970 00:00 UTC and forward.
|
long |
toMillis() |
Calculated as if it was an interval from 1 Jan 1970 00:00 UTC and forward.
|
String |
toString() |
public static Duration parse(String input)
input
- a duration in ISO 8601 formatpublic int amount(Unit unit)
public void forward(Calendar cal)
public void back(Calendar cal)
public void next(Calendar cal)
For instance, a duration of P1M will move the calendar to the start of next month. If the calendar is set to January 12, this method will move the calendar February 1. If set to February, this method will move the calendar to March 1.
cal
- The calendar to move to the next position.public boolean equals(Object o)
Years are normalized to months, weeks to days and hours and minutes to seconds. After normalization, both durations are compared component by component. Iff all components match, this method returns true.
public static Duration fromMillis(long millis)
public Unit precision()
public long toMillis()
public long toDays()
Copyright © 2020 Apptus Technologies AB. All rights reserved.