Interface ITemplateDateUtils


public interface ITemplateDateUtils

A suite of utilities surrounding the use of the Calendar and Date object.

Author:
fernando
  • Method Summary

    Modifier and Type
    Method
    Description
    addDays(Object value, int days)
    Adds a number of days to a value (date, string, number or json node with an string or number) returning a new date.
    addHours(Object value, int hours)
    Adds a number of hours to a value (date, string, number or json node with an string or number) returning a new date.
    addMinutes(Object value, int minutes)
    Adds a number of minutes to a value (date, string, number or json node with an string or number) returning a new date.
    addMonths(Object value, int months)
    Adds a number of months to a value (date, string, number or json node with an string or number) returning a new date.
    addWeeks(Object value, int weeks)
    Adds a number of weeks to a value (date, string, number or json node with an string or number) returning a new date.
    Allocates a Date object and initializes it to represent the specified number of milliseconds since the standard base time known as "the epoch", namely January 1, 1970, 00:00:00 GMT.
    getDate(Object value)
    Returns a date from an object.
    Converts the given date-time text of the pattern yyyy-MM-dd'T'HH:mm:ss.SSSZ (for example, "2021-07-12T13:22:53.744+0100") to a user friendly type.
    Now date.
    Returns the date without truncating the minute.
  • Method Details

    • nowDate

      Date nowDate()
      Now date.
      Returns:
      a date with the current time.
    • truncateMinute

      Date truncateMinute(Date date)
      Returns the date without truncating the minute.
      Parameters:
      date - the date
      Returns:
      same date with 0 seconds
    • createDate

      Date createDate(Long date)
      Allocates a Date object and initializes it to represent the specified number of milliseconds since the standard base time known as "the epoch", namely January 1, 1970, 00:00:00 GMT.
      Parameters:
      date - the milliseconds since January 1, 1970, 00:00:00 GMT.
      Returns:
      the date
      See Also:
    • getDate

      Date getDate(Object value)
      Returns a date from an object. The object could be a date, a number, a string or a json node with a string or a number.
      Parameters:
      value - a date, string, number or a json node containing a number or a string.
      Returns:
      a date or null if the date could not be resolved.
    • addMinutes

      Date addMinutes(Object value, int minutes)
      Adds a number of minutes to a value (date, string, number or json node with an string or number) returning a new date. The original Date is unchanged.
      Parameters:
      value - the date or null
      minutes - the amount to add, may be negative
      Returns:
      the new Date with the minutes added or null if the date could not be resolved from the original value.
    • addHours

      Date addHours(Object value, int hours)
      Adds a number of hours to a value (date, string, number or json node with an string or number) returning a new date. The original Date is unchanged.
      Parameters:
      value - the date or null
      hours - the amount to add, may be negative
      Returns:
      the new Date with the hours added or null if the date could not be resolved from the original value.
    • addDays

      Date addDays(Object value, int days)
      Adds a number of days to a value (date, string, number or json node with an string or number) returning a new date. The original Date is unchanged.
      Parameters:
      value - the date or null
      days - the amount to add, may be negative
      Returns:
      the new Date with the days added or null if the date could not be resolved from the original value.
    • addWeeks

      Date addWeeks(Object value, int weeks)
      Adds a number of weeks to a value (date, string, number or json node with an string or number) returning a new date. The original Date is unchanged.
      Parameters:
      value - the date or null
      weeks - the amount to add, may be negative
      Returns:
      the new Date with the weeks added or null if the date could not be resolved from the original value.
    • addMonths

      Date addMonths(Object value, int months)
      Adds a number of months to a value (date, string, number or json node with an string or number) returning a new date. The original Date is unchanged.
      Parameters:
      value - the date or null
      months - the amount to add, may be negative
      Returns:
      the new Date with the months added or null if the date could not be resolved from the original value.
    • getZonedDateTime

      ZonedDateTime getZonedDateTime(String text)
      Converts the given date-time text of the pattern yyyy-MM-dd'T'HH:mm:ss.SSSZ (for example, "2021-07-12T13:22:53.744+0100") to a user friendly type.
      Parameters:
      text - the date-time with time-zone represented as text
      Returns:
      the ZonedDateTime representing the given string, or null if it does not match the stated pattern.