public class ApacheCommonsDateUtils extends Object
A suite of utilities surrounding the use of the
Calendar
and Date
object.
DateUtils contains a lot of common methods considering manipulations of Dates or Calendars. Some methods require some extra explanation. The truncate, ceiling and round methods could be considered the Math.floor(), Math.ceil() or Math.round versions for dates This way date-FIELDS will be ignored in bottom-up order. As a complement to these methods we've introduced some fragment-methods. With these methods the Date-FIELDS will be ignored in top-down order. Since a date without a year is not a valid date, you have to decide in what kind of date-field you want your result, for instance milliseconds or days.
Modifier and Type | Field and Description |
---|---|
static long |
MILLIS_PER_DAY
Number of milliseconds in a standard day.
|
static long |
MILLIS_PER_HOUR
Number of milliseconds in a standard hour.
|
static long |
MILLIS_PER_MINUTE
Number of milliseconds in a standard minute.
|
static long |
MILLIS_PER_SECOND
Number of milliseconds in a standard second.
|
static int |
MODIFY_CEILING
Constant marker for ceiling
|
static int |
MODIFY_ROUND
Constant marker for rounding
|
static int |
MODIFY_TRUNCATE
Constant marker for truncating
|
static int |
SEMI_MONTH
This is half a month, so this represents whether a date is in the top
or bottom half of the month.
|
static TimeZone |
UTC_TIME_ZONE
The UTC time zone (often referred to as GMT).
|
Constructor and Description |
---|
ApacheCommonsDateUtils() |
Modifier and Type | Method and Description |
---|---|
static void |
modify(Calendar val,
int field,
int modType)
Internal calculation method.
|
public static final TimeZone UTC_TIME_ZONE
public static final long MILLIS_PER_SECOND
public static final long MILLIS_PER_MINUTE
public static final long MILLIS_PER_HOUR
public static final long MILLIS_PER_DAY
public static final int SEMI_MONTH
public static final int MODIFY_TRUNCATE
public static final int MODIFY_ROUND
public static final int MODIFY_CEILING
public static void modify(Calendar val, int field, int modType)
Internal calculation method.
val
- the calendarfield
- the field constantmodType
- type to truncate, round or ceilingArithmeticException
- if the year is over 280 million