Class EventHelper
- java.lang.Object
-
- org.ametys.plugins.calendar.events.EventHelper
-
- All Implemented Interfaces:
LogEnabled
,Serviceable
public final class EventHelper extends Object implements LogEnabled, Serviceable
Helper class that provides a method to check if a date is between two others.
-
-
Field Summary
Fields Modifier and Type Field Description protected static ContentTypeExtensionPoint
_contentTypeEP
The extension point for content typesprotected static AmetysObjectResolver
_resolver
The Ametys object resolver
-
Constructor Summary
Constructors Constructor Description EventHelper()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
enableLogging(Logger logger)
static boolean
inMonth(String monthStartStr, String eventStartStr, String eventEndStr)
Tests if the given event occurs in the given month.static boolean
isBetween(String dateStr, String startStr, String endStr)
Tests if the given date is either: - equal to the first, if there is no end date.static boolean
isDatetime(String contentId, String attributeName)
Tests if the given attribute for the given content is of type datetimestatic String
nextDay(String dateStr)
Tests if the given date is either:static String
nextDay(String dateStr, String format)
Tests if the given date is either:void
service(ServiceManager manager)
-
-
-
Field Detail
-
_resolver
protected static AmetysObjectResolver _resolver
The Ametys object resolver
-
_contentTypeEP
protected static ContentTypeExtensionPoint _contentTypeEP
The extension point for content types
-
-
Constructor Detail
-
EventHelper
public EventHelper()
-
-
Method Detail
-
enableLogging
public void enableLogging(Logger logger)
- Specified by:
enableLogging
in interfaceLogEnabled
-
service
public void service(ServiceManager manager) throws ServiceException
- Specified by:
service
in interfaceServiceable
- Throws:
ServiceException
-
isBetween
public static boolean isBetween(String dateStr, String startStr, String endStr)
Tests if the given date is either: - equal to the first, if there is no end date. - between the two dates, if there is a start and end date.- Parameters:
dateStr
- the date to test.startStr
- start of the interval.endStr
- end of the interval.- Returns:
- true if the date is either equal to the start date or between the start and end date.
-
inMonth
public static boolean inMonth(String monthStartStr, String eventStartStr, String eventEndStr)
Tests if the given event occurs in the given month.- Parameters:
monthStartStr
- The month first day, cannot be null or blank.eventStartStr
- The event start date, can be null or blank only if the end date is set.eventEndStr
- The event end date, can be null or blank only if the end date is set.- Returns:
- true if the event occurs in the given month.
-
nextDay
public static String nextDay(String dateStr)
Tests if the given date is either:- Parameters:
dateStr
- the date to test.- Returns:
- true if the date is either equal to the start date or between the start and end date.
-
nextDay
public static String nextDay(String dateStr, String format)
Tests if the given date is either:- Parameters:
dateStr
- the date to test.format
- the format ("date" or "basicDate").- Returns:
- true if the date is either equal to the start date or between the start and end date.
-
isDatetime
public static boolean isDatetime(String contentId, String attributeName)
Tests if the given attribute for the given content is of type datetime- Parameters:
contentId
- The id of the contentattributeName
- The attribute name- Returns:
- true if the given attribute for the given content is of type datetime
-
-