Package com.logicaldoc.core.automation
Class AutomationDateTool
java.lang.Object
org.apache.velocity.tools.generic.SafeConfig
org.apache.velocity.tools.generic.LocaleConfig
org.apache.velocity.tools.generic.FormatConfig
org.apache.velocity.tools.generic.DateTool
com.logicaldoc.core.automation.AutomationDateTool
- All Implemented Interfaces:
- Serializable
public class AutomationDateTool
extends org.apache.velocity.tools.generic.DateTool
Utility class to handle dates from inside the Automation
- Since:
- 7.3
- Author:
- Marco Meschieri - LogicalDOC
- See Also:
- 
Field SummaryFields inherited from class org.apache.velocity.tools.generic.DateToolTIMEZONE_KEYFields inherited from class org.apache.velocity.tools.generic.FormatConfigDEFAULT_FORMAT, FORMAT_KEYFields inherited from class org.apache.velocity.tools.generic.LocaleConfigDEFAULT_LOCALEFields inherited from class org.apache.velocity.tools.generic.SafeConfigLOCK_CONFIG_KEY, LOGGER_NAME_KEY, SAFE_MODE_KEY, USE_CLASS_LOGGER_KEY
- 
Constructor SummaryConstructorsConstructorDescriptionAutomationDateTool(String dateFormat, String dateFormatLong, String dateFormatShort) AutomationDateTool(Locale locale) 
- 
Method SummaryModifier and TypeMethodDescriptionAdds a given amount of days to a date(you can add negative values to go back in time)addMilliseconds(Date src, int amount) Adds a given amount of milliseconds to a date(you can add negative values to go back in time)addMinutes(Date src, int amount) Adds a given amount of minutes to a date(you can add negative values to go back in time)Adds a given amount of months to a date(you can add negative values to go back in time)addSeconds(Date src, int amount) Adds a given amount of seconds to a date(you can add negative values to go back in time)Adds a given amount of years to a date(you can add negative values to go back in time)Gets the current timeFormats a dateFormats a date using a specific formatFormats a dateFormats a date using a specific formatformatDate(Date date) Formats a date using the normal format that also includes the timeformatDate(Date date, String timeZone) Formats a date using the normal format that also includes the timeformatDateLong(Date date) Formats a date using the long format that includes the time and millisecondsformatDateLong(Date date, String timeZone) Formats a date using the long format that includes the time and millisecondsformatDateShort(Date date) Formats a date using the short format that just includes the dateformatDateShort(Date date, String timeZone) Formats a date using the short format that just includes the dateFormats a date using the ISO format:yyyy-MM-dd'T'HH:mm:ssFormats a date using the SQL format:yyyy-MM-ddRetrieves the default date format with time specification adn millisecondsRetrieves the default date format without time specificationParses a string and to retrieve a datevoidsetDateFormat(String dateFormat) voidsetDateFormatLong(String dateFormatLong) Sets the default long format(date with time)voidsetDateFormatShort(String dateFormatShort) Sets the default short format(date without time)voidsetTimeZone(String timeZone) voidsleep(long milliseconds) Interrupts the current execution thread for a given timelongtoDays(long ms) Calculates how many days are contained in a given amount of millisecondslongtoHours(long ms) Calculates how many hours are contained in a given amount of millisecondslongtoMinutes(long ms) Calculates how many minutes are contained in a given amount of millisecondslongtoMonths(long ms) Calculates how many months are contained in a given amount of millisecondslongtoSeconds(long ms) Calculates how many seconds are contained in a given amount of millisecondslongtoWeeks(long ms) Calculates how many weeks are contained in a given amount of millisecondslongtoYears(long ms) Calculates how many years are contained in a given amount of millisecondsMethods inherited from class org.apache.velocity.tools.generic.DateToolformat, format, format, format, format, format, format, get, get, getCalendar, getDate, getDateFormat, getDateFormat, getDay, getDay, getMonth, getMonth, getSystemCalendar, getSystemDate, getSystemTime, getValue, getValue, getValue, getYear, getYear, toCalendar, toCalendar, toCalendar, toCalendar, toCalendar, toDate, toDate, toDate, toDate, toDate, toDate, toLocalizedPattern, toStringMethods inherited from class org.apache.velocity.tools.generic.FormatConfiggetFormatMethods inherited from class org.apache.velocity.tools.generic.LocaleConfiggetLocale, toLocaleMethods inherited from class org.apache.velocity.tools.generic.SafeConfigconfigure, isConfigLocked, isSafeMode
- 
Constructor Details- 
AutomationDateTool
- 
AutomationDateTool
- 
AutomationDateToolpublic AutomationDateTool()
 
- 
- 
Method Details- 
formatFormats a date- Parameters:
- date- the date to format
- timeZone- the time zone
- time- if the output must contain the time also
- Returns:
- the formatted string
 
- 
formatFormats a date- Parameters:
- date- the date to format
- time- if the output must contain the time also
- Returns:
- the formatted string
 
- 
formatDateFormats a date using the normal format that also includes the time- Parameters:
- date- the date to format
- timeZone- the time zone
- Returns:
- the formatted string
 
- 
formatDateFormats a date using the normal format that also includes the time- Parameters:
- date- the date to format
- Returns:
- the formatted string
 
- 
formatDateShortFormats a date using the short format that just includes the date- Parameters:
- date- the date to format
- timeZone- the time zone
- Returns:
- the formatted string
 
- 
formatDateShortFormats a date using the short format that just includes the date- Parameters:
- date- the date to format
- Returns:
- the formatted string
 
- 
formatDateLongFormats a date using the long format that includes the time and milliseconds- Parameters:
- date- the date to format
- timeZone- the time zone
- Returns:
- the formatted string
 
- 
formatDateLongFormats a date using the long format that includes the time and milliseconds- Parameters:
- date- the date to format
- Returns:
- the formatted string
 
- 
formatISOFormats a date using the ISO format:yyyy-MM-dd'T'HH:mm:ss- Parameters:
- date- the date to format
- Returns:
- the formatted string
 
- 
formatSQLFormats a date using the SQL format:yyyy-MM-dd- Parameters:
- date- the date to format
- Returns:
- the formatted string
 
- 
formatFormats a date using a specific format- Parameters:
- date- the date to format
- format- the format to use eg: dd/MM/yyyy
- timeZone- the time zone
- Returns:
- the formatted string
- See Also:
 
- 
formatFormats a date using a specific format- Parameters:
- date- the date to format
- format- the format to use eg: dd/MM/yyyy
- Returns:
- the formatted string
- See Also:
 
- 
parseParses a string and to retrieve a date- Parameters:
- date- string to parse
- format- the format to use
- Returns:
- the parsed date
- See Also:
 
- 
getDateFormatShortRetrieves the default date format without time specification- Returns:
- the default date short format
 
- 
setDateFormatShortSets the default short format(date without time)- Parameters:
- dateFormatShort- the short format
 
- 
getDateFormatLongRetrieves the default date format with time specification adn milliseconds- Returns:
- the default date long format
 
- 
setDateFormatLongSets the default long format(date with time)- Parameters:
- dateFormatLong- the long format
 
- 
currentTimeGets the current time- Returns:
- the current time
 
- 
addYearsAdds a given amount of years to a date(you can add negative values to go back in time)- Parameters:
- src- the date to use
- amount- number of years
- Returns:
- the new date
 
- 
addMonthsAdds a given amount of months to a date(you can add negative values to go back in time)- Parameters:
- src- the date to use
- amount- number of months
- Returns:
- the new date
 
- 
addDaysAdds a given amount of days to a date(you can add negative values to go back in time)- Parameters:
- src- the date to use
- amount- number of days
- Returns:
- the new date
 
- 
addMinutesAdds a given amount of minutes to a date(you can add negative values to go back in time)- Parameters:
- src- the date to use
- amount- number of minutes
- Returns:
- the new date
 
- 
addSecondsAdds a given amount of seconds to a date(you can add negative values to go back in time)- Parameters:
- src- the date to use
- amount- number of seconds
- Returns:
- the new date
 
- 
addMillisecondsAdds a given amount of milliseconds to a date(you can add negative values to go back in time)- Parameters:
- src- the date to use
- amount- number of milliseconds
- Returns:
- the new date
 
- 
toDayspublic long toDays(long ms) Calculates how many days are contained in a given amount of milliseconds- Parameters:
- ms- the milliseconds
- Returns:
- number of days
 
- 
toHourspublic long toHours(long ms) Calculates how many hours are contained in a given amount of milliseconds- Parameters:
- ms- the milliseconds
- Returns:
- number of hours
 
- 
toMinutespublic long toMinutes(long ms) Calculates how many minutes are contained in a given amount of milliseconds- Parameters:
- ms- the milliseconds
- Returns:
- number of minutes
 
- 
toMonthspublic long toMonths(long ms) Calculates how many months are contained in a given amount of milliseconds- Parameters:
- ms- the milliseconds
- Returns:
- number of months
 
- 
toSecondspublic long toSeconds(long ms) Calculates how many seconds are contained in a given amount of milliseconds- Parameters:
- ms- the milliseconds
- Returns:
- number of seconds
 
- 
toWeekspublic long toWeeks(long ms) Calculates how many weeks are contained in a given amount of milliseconds- Parameters:
- ms- the milliseconds
- Returns:
- number of weeks
 
- 
toYearspublic long toYears(long ms) Calculates how many years are contained in a given amount of milliseconds- Parameters:
- ms- the milliseconds
- Returns:
- number of years
 
- 
getDateFormat
- 
setDateFormat
- 
getTimeZone- Overrides:
- getTimeZonein class- org.apache.velocity.tools.generic.DateTool
 
- 
setTimeZone
- 
sleepInterrupts the current execution thread for a given time- Parameters:
- milliseconds- Number of milliseconds to wait
- Throws:
- InterruptedException- Raised if any thread has interrupted the current thread
 
 
-