Serializable
, Comparable<Unit>
public enum Unit extends Enum<Unit>
Enum Constant | Description |
---|---|
DAY |
|
HOUR |
|
MINUTE |
|
MONTH |
|
SECOND |
|
WEEK |
|
YEAR |
Modifier and Type | Method | Description |
---|---|---|
void |
add(Calendar cal,
int amount) |
Moves a calendar
amount units in time. |
void |
ceil(Calendar cal) |
Moves the calendar time forwards to the closest whole unit.
|
String |
displayName(Calendar cal) |
|
void |
floor(Calendar cal) |
Moves the calendar time backwards to the closest whole unit.
|
static Unit |
forSymbol(String symbol) |
|
void |
round(Calendar cal) |
Moves the calendar time to the closest whole unit.
|
String |
symbol() |
|
static Unit |
valueOf(String name) |
Returns the enum constant of this type with the specified name.
|
static Unit[] |
values() |
Returns an array containing the constants of this enum type, in
the order they are declared.
|
public static final Unit SECOND
public static final Unit MINUTE
public static final Unit HOUR
public static final Unit DAY
public static final Unit WEEK
public static final Unit MONTH
public static final Unit YEAR
public static Unit[] values()
for (Unit c : Unit.values()) System.out.println(c);
public static Unit valueOf(String name)
name
- the name of the enum constant to be returned.IllegalArgumentException
- if this enum type has no constant with the specified nameNullPointerException
- if the argument is nullpublic String displayName(Calendar cal)
cal
- The calendar to get the string representation for.public void add(Calendar cal, int amount)
amount
units in time.
Use a positive amount to move forward and a negative amount to move backwards.cal
- The calendar to change time for.amount
- The number of units to move the time of the calendar.public void floor(Calendar cal)
cal
- The calendar to floor.public void ceil(Calendar cal)
cal
- The calendar to ceil.public void round(Calendar cal)
cal
- The calendar to round.public String symbol()
public static Unit forSymbol(String symbol) throws UnknownUnitException
symbol
- A string representation of the unit.UnknownUnitException
- If no unit is associated with the symbol.Copyright © 2021 Apptus Technologies AB. All rights reserved.