public class Period extends Object implements Serializable
Period class is used to handle time periods. A period consists of a
group of 6 numbers, each specifying an amount of units, i.e. 6 months and 3 hours.
The Period also provides convenient methods to perform operations on
Calendars.| Modifier and Type | Field and Description |
|---|---|
static int |
DAYS
Identifier for the number of days field.
|
static int |
HOURS
Identifier for the number of hours field.
|
static int |
MINUTES
Identifier for the number of minutes field.
|
static int |
MONTHS
Identifier for the number of months field.
|
static int |
SECONDS
Identifier for the number of seconds field.
|
static int |
YEARS
Identifier for the number of years field.
|
| Constructor and Description |
|---|
Period(short years,
short months,
short days,
short hours,
short minutes,
short seconds)
Creates a new Period from the given values.
|
Period(String raw)
Creates a new Period from a string representation.
|
| Modifier and Type | Method and Description |
|---|---|
Calendar |
add(Calendar source)
Adds this period to the provided calendar.
|
boolean |
equals(Object o) |
short |
get(int field)
Gets the value of a specific field of the period.
|
int |
hashCode() |
Calendar |
subtract(Calendar source)
Subtracts this period from the provided calendar.
|
String |
toString()
Returns a fixed size String representation of the period, where each field has 6
digits allocated.
|
public static final int YEARS
public static final int MONTHS
public static final int DAYS
public static final int HOURS
public static final int MINUTES
public static final int SECONDS
public Period(String raw)
Example: "0:6:0:3:0:0" represents a period of
6 months and 3 hours.
raw - the String representation of the period.public Period(short years,
short months,
short days,
short hours,
short minutes,
short seconds)
years - the number of years contained in the period.months - the number of months contained in the period.days - the number of days contained in the period.hours - the number of hours contained in the period.minutes - the number of minutes contained in the period.seconds - the number of seconds contained in the period.public String toString()
public Calendar add(Calendar source)
source - the reference time.public Calendar subtract(Calendar source)
source - the reference time.public short get(int field)
field - one of the identifier constants.Copyright © 2016 Eclipse Stardust. All Rights Reserved.