public enum DateUnit extends Enum<DateUnit> implements SimpleDatatype<String>
TimeUnit| Enum Constant and Description |
|---|
DAY
The day of the month starting with 1.
|
MONTH
The month of the year starting with 1 (NOT 0 like
Calendar does). |
WEEK
The week (of the year) starting with 1.
|
YEAR
The year.
|
| Modifier and Type | Field and Description |
|---|---|
private int |
calendarId |
private String |
title |
private String |
value |
| Modifier and Type | Method and Description |
|---|---|
static DateUnit |
fromValue(String value)
This method gets the
DateUnit for the given value. |
int |
getCalendarField(Calendar calendar)
This method delegates to
Calendar.get(int). |
int |
getCalendarId()
This method gets the ID constant for
Calendar operations such as
Calendar.get(int). |
String |
getValue()
This method returns the raw value of this datatype.
|
void |
setCalendarField(Calendar calendar,
int unitValue)
This method delegates to
Calendar.set(int, int). |
String |
toString()
|
static DateUnit |
valueOf(String name)
Returns the enum constant of this type with the specified name.
|
static DateUnit[] |
values()
Returns an array containing the constants of this enum type, in
the order they are declared.
|
public static final DateUnit DAY
public static final DateUnit WEEK
public static final DateUnit MONTH
Calendar does).Monthpublic static final DateUnit YEAR
private final String value
private final String title
private final int calendarId
public static DateUnit[] values()
for (DateUnit c : DateUnit.values()) System.out.println(c);
public static DateUnit 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 getValue()
SimpleDatatypeString
, Character, Boolean, any type of Number, any type of java.time.LocalDate, etc.).getValue in interface AttributeReadValue<String>getValue in interface SimpleDatatype<String>public String toString()
DatatypeString representation of this Datatype. While the general contract of
Object.toString() is very weak and mainly used for debugging, the contract here is very strong. The
returned String has to be suitable for end-users and official output to any kind of sink. NlsMessage for
this purpose and implement NlsObject if you want to support I18N/L10N.public int getCalendarField(Calendar calendar)
Calendar.get(int). However, it will return the month in a natural way from 1 to
12. Java Calendar returns 0 for January instead of 1 and so forth what is the cause of many mistakes.public void setCalendarField(Calendar calendar, int unitValue)
Calendar.set(int, int). However, it will treat the month in a natural way from 1
to 12. Java Calendar expects 0 for January instead of 1 and so forth what is the cause of many mistakes.calendar - is the Calendar.unitValue - is the value to set.public int getCalendarId()
Calendar operations such as
Calendar.get(int).Copyright © 2001–2016 mmm-Team. All rights reserved.