Package com.jidesoft.grouper.date
Class DateGrouper
java.lang.Object
com.jidesoft.grouper.AbstractObjectGrouper
com.jidesoft.grouper.date.DateGrouper
- All Implemented Interfaces:
ObjectGrouper
- Direct Known Subclasses:
DateDayOfMonthGrouper
,DateDayOfWeekGrouper
,DateDayOfWeekInMonthGrouper
,DateDayOfYearGrouper
,DateMonthGrouper
,DateQuarterGrouper
,DateWeekOfMonthGrouper
,DateWeekOfYearGrouper
,DateYearGrouper
An abstract Grouper which can take data type such as Date, Calendar or Long and provide
getCalendarFieldAsInt(Object, int)
and getCalendarField(Object, int)
methods to access the field of the
Calendar.-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic Object
getCalendarField
(Object value, int field) Gets the field value from the value.static int
getCalendarFieldAsInt
(Object value, int field) Gets the field value from the value.static Calendar
To avoid creating too many instance of Calendar and improve the performance,getCalendarField(Object, int)
andgetCalendarFieldAsInt(Object, int)
will use a cached instance of Calendar if the value passed in is Date or Long.Class<?>
getType()
Gets the group value type.Methods inherited from class com.jidesoft.grouper.AbstractObjectGrouper
getComparatorContext, getConverterContext
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.jidesoft.grouper.ObjectGrouper
getName, getValue
-
Field Details
-
INSTANCE
-
-
Constructor Details
-
DateGrouper
public DateGrouper()
-
-
Method Details
-
getCalendarInstance
To avoid creating too many instance of Calendar and improve the performance,getCalendarField(Object, int)
andgetCalendarFieldAsInt(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.- Returns:
- the Calendar instance used by the two getCalendarField methods.
-
getCalendarField
Gets the field value from the value.- Parameters:
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 usinggetCalendarInstance()
in case you want to customize it.field
- the field as defined in Calendar such as Calender.YEAR, Calendar.DAY_OF_MONTH.- Returns:
- the field value. Null if the value that was passed in is null.
- Throws:
IllegalArgumentException
- if the value is not a Date, a Long or a Calendar.
-
getCalendarFieldAsInt
Gets the field value from the value.- Parameters:
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 usinggetCalendarInstance()
in case you want to customize it.field
- the field as defined in Calendar such as Calender.YEAR, Calendar.DAY_OF_MONTH.- Returns:
- the field value. -1 if the value that was passed in is null.
- Throws:
IllegalArgumentException
- if the value is not a Date, a Long or a Calendar.
-
getType
Description copied from interface:ObjectGrouper
Gets the group value type. It should be the type of the value that is returned from the getGroupValue.- Returns:
- the group value type.
-