ObjectGrouper
DateDayOfMonthGrouper
, DateDayOfWeekGrouper
, DateDayOfWeekInMonthGrouper
, DateDayOfYearGrouper
, DateMonthGrouper
, DateQuarterGrouper
, DateWeekOfMonthGrouper
, DateWeekOfYearGrouper
, DateYearGrouper
public abstract class DateGrouper extends AbstractObjectGrouper
getCalendarFieldAsInt(Object, int)
and getCalendarField(Object, int)
methods to access the field of the
Calendar.Modifier and Type | Field | Description |
---|---|---|
protected static java.util.Calendar |
INSTANCE |
Constructor | Description |
---|---|
DateGrouper() |
Modifier and Type | Method | Description |
---|---|---|
static java.lang.Object |
getCalendarField(java.lang.Object value,
int field) |
Gets the field value from the value.
|
static int |
getCalendarFieldAsInt(java.lang.Object value,
int field) |
Gets the field value from the value.
|
static java.util.Calendar |
getCalendarInstance() |
To avoid creating too many instance of Calendar and improve the performance,
getCalendarField(Object,
int) and getCalendarFieldAsInt(Object, int) will use a cached instance of Calendar if the value passed
in is Date or Long. |
java.lang.Class<?> |
getType() |
Gets the group value type.
|
getComparatorContext, getConverterContext
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getName, getValue
public static java.util.Calendar getCalendarInstance()
getCalendarField(Object,
int)
and getCalendarFieldAsInt(Object, int)
will use a cached instance of Calendar if the value passed
in is Date or Long. By default, the cached Calendar instance was created from Calendar.getInstance(). This method
will give you this instance and allow you to modify it. For example, setting a different time-zone. Since this
instance is static, there is only one instance for the whole application. So just so you know, if you modify it,
it will affect all the usages.public static java.lang.Object getCalendarField(java.lang.Object value, int field)
value
- a Date, Long or Calendar. If the value is a Date or a Long, we will use a cached Calendar instance
to get the field value. This cached Calendar instance can be retrieved using getCalendarInstance()
in case you want to customize it.field
- the field as defined in Calendar such as Calender.YEAR, Calendar.DAY_OF_MONTH.java.lang.IllegalArgumentException
- if the value is not a Date, a Long or a Calendar.public static int getCalendarFieldAsInt(java.lang.Object value, int field)
value
- a Date, Long or Calendar. If the value is a Date or a Long, we will use a cached Calendar instance
to get the field value. This cached Calendar instance can be retrieved using getCalendarInstance()
in case you want to customize it.field
- the field as defined in Calendar such as Calender.YEAR, Calendar.DAY_OF_MONTH.java.lang.IllegalArgumentException
- if the value is not a Date, a Long or a Calendar.public java.lang.Class<?> getType()
ObjectGrouper