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 java.lang.Object

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


Constructor Summary
Utils()
           
 
Method Summary
static boolean checkTime(java.lang.String strTime)
          Return a boolean: if the time is well formed return true, else return false
static java.lang.String getDate(java.util.Calendar calendar)
          Constructs a 8 digits date string YYYYMMDD
static java.lang.String getDate(int nYear, int nMonth, int nDay)
          Constructs a 8 digits date string code YYYYMMDD
static java.lang.String getDateToday()
          Returns a the date code of today
static int getDay(java.lang.String strDate)
          Returns the day of month from a date code
static java.lang.String getDayAfter(java.lang.String strDate, int n)
          Returns a date code corresponding to a calendar roll of n days forward
static java.lang.String getDayLabel(java.lang.String strDate, java.util.Locale locale)
          Returns the day as an international formatted string corresponding to the date code
static java.util.Calendar getFirstDayOfWeek(java.lang.String strDate)
          Returns the first monday of a week as a formatted string corresponding to the date code
static int getMonth(java.lang.String strDate)
          Returns the month from a date code
static java.lang.String getMonthLabel(java.lang.String strDate, java.util.Locale locale)
          Returns the month as a formatted string corresponding to the date code
static java.lang.String getNextDay(java.lang.String strDate)
          Returns a date code corresponding to a calendar roll of one day forward
static java.lang.String getNextMonth(java.lang.String strDate)
          Returns a date code corresponding to a calendar roll of one month
static java.lang.String getNextWeek(java.lang.String strDate)
          Returns a date code corresponding to a calendar roll of one week forward
static java.lang.String getPreviousDay(java.lang.String strDate)
          Returns a date code corresponding to a calendar roll of one day backward
static java.lang.String getPreviousMonth(java.lang.String strDate)
          Returns a date code corresponding to a calendar roll of one month backward
static java.lang.String getPreviousWeek(java.lang.String strDate)
          Returns a date code corresponding to a calendar roll of one week backward
static java.lang.String getWeekDayLabel(java.lang.String strDate, java.util.Locale locale)
          Returns the day as an international formatted string corresponding to the date code
static java.lang.String getWeekLabel(java.lang.String strDate, java.util.Locale locale)
          Returns the Week as a formatted string corresponding to the date code
static int getYear(java.lang.String strDate)
          Returns the year from a date code
static boolean isDayOff(java.util.Calendar calendar)
          Checks if the day if Off (ie: Sunday) or not
static boolean isValid(java.lang.String strDate)
          Checks a date code
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Utils

public Utils()
Method Detail

getDate

public static java.lang.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 java.lang.String getDate(java.util.Calendar calendar)
Constructs a 8 digits date string YYYYMMDD

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

getDateToday

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

Returns:
The date code

getYear

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

Parameters:
strDate - The date code
Returns:
The Year

getMonth

public static int getMonth(java.lang.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(java.lang.String strDate)
Returns the day of month from a date code

Parameters:
strDate - The date code
Returns:
The day

getMonthLabel

public static java.lang.String getMonthLabel(java.lang.String strDate,
                                             java.util.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 java.lang.String getWeekLabel(java.lang.String strDate,
                                            java.util.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 java.util.Calendar getFirstDayOfWeek(java.lang.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 java.lang.String getDayLabel(java.lang.String strDate,
                                           java.util.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 java.lang.String getWeekDayLabel(java.lang.String strDate,
                                               java.util.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 java.lang.String getNextMonth(java.lang.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 java.lang.String getPreviousMonth(java.lang.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 java.lang.String getPreviousWeek(java.lang.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 java.lang.String getNextWeek(java.lang.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 java.lang.String getNextDay(java.lang.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 java.lang.String getPreviousDay(java.lang.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(java.lang.String strDate)
Checks a date code

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

isDayOff

public static boolean isDayOff(java.util.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(java.lang.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 java.lang.String getDayAfter(java.lang.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


Copyright © 2008 Mairie de Paris. All Rights Reserved.