fr.paris.lutece.plugins.calendar.service
Class Utils

java.lang.Object
  extended by fr.paris.lutece.plugins.calendar.service.Utils

public final class Utils
extends Object

This class provides utils features to manipulate and convert calendars, date as string, ...


Method Summary
static boolean checkTime(String strTime)
          Return a boolean: if the time is well formed return true, else return false
static List<AgendaResource> getAgendaResourcesWithEvents()
          Get the multi agenda from database
static List<AgendaResource> getAgendaResourcesWithOccurrences()
          Get the multi agenda from database
static List<AgendaResource> getAgendaResourcesWithOccurrences(javax.servlet.http.HttpServletRequest request)
          Get all agendas from database checkin the security
static List<AgendaResource> getAgendaResourcesWithOccurrencesIds()
          Get the multi agenda from database with occurrences ordered by id
static Agenda getAgendaWithEvents(String strAgenda, javax.servlet.http.HttpServletRequest request)
          Get a specified agenda from database with events
static Agenda getAgendaWithOccurrences(String strAgenda, javax.servlet.http.HttpServletRequest request)
          Get a specified agenda from database with occurrences
static Agenda getAgendaWithOccurrencesOrderedbyId(String strAgenda, javax.servlet.http.HttpServletRequest request)
          Get a specified agenda from database with occurrences
static String[] getCalendarIds(javax.servlet.http.HttpServletRequest request)
          Get all calendar ids that the user is authorized to visualize
static String getDate(Calendar calendar)
          Constructs a 8 digits date string YYYYMMDD
static String getDate(Date dateDigit)
          Constructs a digit string from a date object
static String getDate(int nYear, int nMonth, int nDay)
          Constructs a 8 digits date string code YYYYMMDD
static Date getDate(String strDate)
          Constructs a Date object from YYYYMMDD
static Date getDateForward(Date dateDay, int nPeriodicity, int nOccurrence, String[] arrayExcludedDays)
          Returns a date code corresponding to a calendar roll of n days forward
static String getDateToday()
          Returns a the date code of today
static int getDay(String strDate)
          Returns the day of month from a date code
static Date getDayAfter(Date dateDayAfter, int n)
          Returns a date code corresponding to a calendar roll of n days forward
static String getDayAfter(String strDate, int n)
          Returns a date code corresponding to a calendar roll of n days forward
static String getDayLabel(String strDate, Locale locale)
          Returns the day as an international formatted string corresponding to the date code
static int getDayOfWeek(String strDate)
          Get the day of week of a given date using the pattern DATE_PATTERN
static Calendar getFirstDayOfWeek(String strDate)
          Returns the first monday of a week as a formatted string corresponding to the date code
static int getMonth(String strDate)
          Returns the month from a date code
static String getMonthLabel(String strDate, Locale locale)
          Returns the month as a formatted string corresponding to the date code
static String getNextDay(String strDate)
          Returns a date code corresponding to a calendar roll of one day forward
static String getNextMonth(String strDate)
          Returns a date code corresponding to a calendar roll of one month
static String getNextMonth(String strDateRef, int nCptDate)
          Returns a date code corresponding to a calendar roll of one month
static String getNextWeek(String strDate)
          Returns a date code corresponding to a calendar roll of one week forward
static int getOccurrenceWithinTwoDates(Date dateStart, Date dateEnd, String[] arrayExcludedDays)
          Returns a date code corresponding to a calendar roll of one month
static String getPreviousDay(String strDate)
          Returns a date code corresponding to a calendar roll of one day backward
static String getPreviousMonth(String strDate)
          Returns a date code corresponding to a calendar roll of one month backward
static String getPreviousWeek(String strDate)
          Returns a date code corresponding to a calendar roll of one week backward
static String getWeekDayLabel(String strDate, Locale locale)
          Returns the day as an international formatted string corresponding to the date code
static String getWeekLabel(String strDate, Locale locale)
          Returns the Week as a formatted string corresponding to the date code
static int getYear(String strDate)
          Returns the year from a date code
static boolean isDayExcluded(int nDayOfWeek, String[] arrayExcludedDays)
          Check if a day is in the list of excluded days
static boolean isDayOff(Calendar calendar)
          Checks if the day if Off (ie: Sunday) or not
static boolean isValid(String strDate)
          Checks a date code
static boolean isValidDate(Date dateEvent)
          Checks a date code
static void loadAgendaEvents(AgendaResource agenda, fr.paris.lutece.portal.service.plugin.Plugin plugin)
          Return the agenda
static void loadAgendaOccurrences(AgendaResource agenda, fr.paris.lutece.portal.service.plugin.Plugin plugin)
          Return the agenda
static void loadAgendaOccurrencesOrderedById(AgendaResource agenda, fr.paris.lutece.portal.service.plugin.Plugin plugin)
          Return the occurrences of an agenda ordered by id
static String parseHtmlToPlainTextString(String strHTML)
          Parse a HTML string into plain text
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getDate

public static String getDate(int nYear,
                             int nMonth,
                             int nDay)
Constructs a 8 digits date string code YYYYMMDD

Parameters:
nYear - The Year
nMonth - The month index (0-11)
nDay - The day of the month (1-31)
Returns:
The date string code

getDate

public static String getDate(Calendar calendar)
Constructs a 8 digits date string YYYYMMDD

Parameters:
calendar - A calendar positionned on the date
Returns:
The date code

getDateToday

public static String getDateToday()
Returns a the date code of today

Returns:
The date code

getYear

public static int getYear(String strDate)
Returns the year from a date code

Parameters:
strDate - The date code
Returns:
The Year

getMonth

public static int getMonth(String strDate)
Returns the month from a date code

Parameters:
strDate - The date code
Returns:
The month index (0 - 11)

getDay

public static int getDay(String strDate)
Returns the day of month from a date code

Parameters:
strDate - The date code
Returns:
The day

getMonthLabel

public static String getMonthLabel(String strDate,
                                   Locale locale)
Returns the month as a formatted string corresponding to the date code

Parameters:
locale - The locale used for display settings
strDate - The date code
Returns:
The month label

getWeekLabel

public static String getWeekLabel(String strDate,
                                  Locale locale)
Returns the Week as a formatted string corresponding to the date code

Parameters:
locale - The locale used for display settings
strDate - The date code
Returns:
The week label

getFirstDayOfWeek

public static Calendar getFirstDayOfWeek(String strDate)
Returns the first monday of a week as a formatted string corresponding to the date code

Parameters:
strDate - The date code
Returns:
The first day label

getDayLabel

public static String getDayLabel(String strDate,
                                 Locale locale)
Returns the day as an international formatted string corresponding to the date code

Parameters:
locale - The locale used for display settings
strDate - The date code
Returns:
The day as a string

getWeekDayLabel

public static String getWeekDayLabel(String strDate,
                                     Locale locale)
Returns the day as an international formatted string corresponding to the date code

Parameters:
locale - The locale used for display settings
strDate - The date code
Returns:
The day as a string

getNextMonth

public static String getNextMonth(String strDate)
Returns a date code corresponding to a calendar roll of one month

Parameters:
strDate - The date code
Returns:
A date code one month later

getPreviousMonth

public static String getPreviousMonth(String strDate)
Returns a date code corresponding to a calendar roll of one month backward

Parameters:
strDate - The date code
Returns:
A new date code one month earlier

getPreviousWeek

public static String getPreviousWeek(String strDate)
Returns a date code corresponding to a calendar roll of one week backward

Parameters:
strDate - The date code
Returns:
A new date code one month earlier

getNextWeek

public static String getNextWeek(String strDate)
Returns a date code corresponding to a calendar roll of one week forward

Parameters:
strDate - The date code
Returns:
A new date code one month earlier

getNextDay

public static String getNextDay(String strDate)
Returns a date code corresponding to a calendar roll of one day forward

Parameters:
strDate - The date code
Returns:
A new date code one month earlier

getPreviousDay

public static String getPreviousDay(String strDate)
Returns a date code corresponding to a calendar roll of one day backward

Parameters:
strDate - The date code
Returns:
A new date code one month earlier

isValid

public static boolean isValid(String strDate)
Checks a date code

Parameters:
strDate - The date code
Returns:
True if valid otherwise false

isDayOff

public static boolean isDayOff(Calendar calendar)
Checks if the day if Off (ie: Sunday) or not

Parameters:
calendar - A calendar object positionned on the day to check
Returns:
True if the day if Off, otherwise false

checkTime

public static boolean checkTime(String strTime)
Return a boolean: if the time is well formed return true, else return false

Parameters:
strTime - The time
Returns:
a boolean

getDayAfter

public static String getDayAfter(String strDate,
                                 int n)
Returns a date code corresponding to a calendar roll of n days forward

Parameters:
n - number of days to roll
strDate - The date code
Returns:
A new date code one month earlier

getDayAfter

public static Date getDayAfter(Date dateDayAfter,
                               int n)
Returns a date code corresponding to a calendar roll of n days forward

Parameters:
n - number of days to roll
dateDayAfter - The date
Returns:
A new date code with n days forward

getDateForward

public static Date getDateForward(Date dateDay,
                                  int nPeriodicity,
                                  int nOccurrence,
                                  String[] arrayExcludedDays)
Returns a date code corresponding to a calendar roll of n days forward

Parameters:
dateDay - the reference date
nPeriodicity - the frequence of an occurrence day, week, month
nOccurrence - the number of occurrences
arrayExcludedDays - list of excluded days
Returns:
A new date code one month earlier

getDate

public static Date getDate(String strDate)
Constructs a Date object from YYYYMMDD

Parameters:
strDate - a 8 digits date string YYYYMMDD
Returns:
The date code

getDate

public static String getDate(Date dateDigit)
Constructs a digit string from a date object

Parameters:
dateDigit - The date code
Returns:
strDate a 8 digits date string YYYYMMDD

getNextMonth

public static String getNextMonth(String strDateRef,
                                  int nCptDate)
Returns a date code corresponding to a calendar roll of one month

Parameters:
strDateRef - The date reference
nCptDate - The number of month to add
Returns:
A date code incremented with strDateRef parameter

getOccurrenceWithinTwoDates

public static int getOccurrenceWithinTwoDates(Date dateStart,
                                              Date dateEnd,
                                              String[] arrayExcludedDays)
Returns a date code corresponding to a calendar roll of one month

Parameters:
dateStart - The date start
dateEnd - The date end
arrayExcludedDays - list of excluded days
Returns:
A date code incremented with strDateRef parameter

getAgendaWithEvents

public static Agenda getAgendaWithEvents(String strAgenda,
                                         javax.servlet.http.HttpServletRequest request)
Get a specified agenda from database with events

Parameters:
strAgenda - The name of the agenda to get
request - The HTTP request
Returns:
An agenda object

getAgendaWithOccurrences

public static Agenda getAgendaWithOccurrences(String strAgenda,
                                              javax.servlet.http.HttpServletRequest request)
Get a specified agenda from database with occurrences

Parameters:
strAgenda - The agenda to get
request - The HTTP request
Returns:
An agenda object

getAgendaWithOccurrencesOrderedbyId

public static Agenda getAgendaWithOccurrencesOrderedbyId(String strAgenda,
                                                         javax.servlet.http.HttpServletRequest request)
Get a specified agenda from database with occurrences

Parameters:
strAgenda - The agenda to get
request - The HTTP request
Returns:
An agenda object

getAgendaResourcesWithOccurrences

public static List<AgendaResource> getAgendaResourcesWithOccurrences(javax.servlet.http.HttpServletRequest request)
Get all agendas from database checkin the security

Parameters:
request - The request
Returns:
An agenda object

getAgendaResourcesWithOccurrences

public static List<AgendaResource> getAgendaResourcesWithOccurrences()
Get the multi agenda from database

Returns:
An agenda object

getAgendaResourcesWithEvents

public static List<AgendaResource> getAgendaResourcesWithEvents()
Get the multi agenda from database

Returns:
An agenda object

getAgendaResourcesWithOccurrencesIds

public static List<AgendaResource> getAgendaResourcesWithOccurrencesIds()
Get the multi agenda from database with occurrences ordered by id

Returns:
An agenda object

loadAgendaOccurrences

public static void loadAgendaOccurrences(AgendaResource agenda,
                                         fr.paris.lutece.portal.service.plugin.Plugin plugin)
Return the agenda

Parameters:
agenda - The agenda
plugin - The plugin

loadAgendaOccurrencesOrderedById

public static void loadAgendaOccurrencesOrderedById(AgendaResource agenda,
                                                    fr.paris.lutece.portal.service.plugin.Plugin plugin)
Return the occurrences of an agenda ordered by id

Parameters:
agenda - The agenda
plugin - The plugin

loadAgendaEvents

public static void loadAgendaEvents(AgendaResource agenda,
                                    fr.paris.lutece.portal.service.plugin.Plugin plugin)
Return the agenda

Parameters:
agenda - The agenda
plugin - The plugin

isValidDate

public static boolean isValidDate(Date dateEvent)
Checks a date code

Parameters:
dateEvent - The date code
Returns:
True if valid otherwise false

parseHtmlToPlainTextString

public static String parseHtmlToPlainTextString(String strHTML)
Parse a HTML string into plain text

Parameters:
strHTML - The HTMl to parse
Returns:
The Plain text describing the given HTML

getCalendarIds

public static String[] getCalendarIds(javax.servlet.http.HttpServletRequest request)
Get all calendar ids that the user is authorized to visualize

Parameters:
request - HttpServletRequest
Returns:
String array

getDayOfWeek

public static int getDayOfWeek(String strDate)
Get the day of week of a given date using the pattern DATE_PATTERN

Parameters:
strDate - The date to parse
Returns:
The day of week of the given date, or -1 if the date could not be parsed

isDayExcluded

public static boolean isDayExcluded(int nDayOfWeek,
                                    String[] arrayExcludedDays)
Check if a day is in the list of excluded days

Parameters:
nDayOfWeek - the day to check
arrayExcludedDays - the array of excluded days
Returns:
true if it is excluded, false otherwise


Copyright © 2014 Mairie de Paris. All Rights Reserved.