public static enum DateTime.DayOverflow extends java.lang.Enum<DateTime.DayOverflow>
Months are different from other units of time, since the length of a month is not fixed, but rather varies with both month and year. This leads to problems. Take the following simple calculation, for example :
May 31 + 1 month = ?
What's the answer? Since there is no such thing as June 31, the result of this operation is inherently ambiguous. This DayOverflow enumeration lists the various policies for treating such situations, as supported by DateTime.
This table illustrates how the policies behave :
| Date | DayOverflow | Result |
|---|---|---|
| May 31 + 1 Month | LastDay | June 30 |
| May 31 + 1 Month | FirstDay | July 1 |
| December 31, 2001 + 2 Months | Spillover | March 3 |
| May 31 + 1 Month | Abort | RuntimeException |
| Enum Constant and Description |
|---|
Abort
Throw a RuntimeException.
|
FirstDay
Coerce the day to the first day of the next month.
|
LastDay
Coerce the day to the last day of the month.
|
Spillover
Spillover the day into the next month.
|
| Modifier and Type | Method and Description |
|---|---|
static DateTime.DayOverflow |
valueOf(java.lang.String name)
Returns the enum constant of this type with the specified name.
|
static DateTime.DayOverflow[] |
values()
Returns an array containing the constants of this enum type, in
the order they are declared.
|
public static final DateTime.DayOverflow LastDay
public static final DateTime.DayOverflow FirstDay
public static final DateTime.DayOverflow Spillover
public static final DateTime.DayOverflow Abort
public static DateTime.DayOverflow[] values()
for (DateTime.DayOverflow c : DateTime.DayOverflow.values()) System.out.println(c);
public static DateTime.DayOverflow valueOf(java.lang.String name)
name - the name of the enum constant to be returned.java.lang.IllegalArgumentException - if this enum type has no constant
with the specified namejava.lang.NullPointerException - if the argument is nullCopyright © 2014. All Rights Reserved.