Options
All
  • Public
  • Public/Protected
  • All
Menu

PrimeFaces SimpleDateFormat widget

Code ported from Tim Down's http://www.timdown.co.uk/code/simpledateformat.php

Helper widget for working with Dates and date formats.

Type Parameters

Hierarchy

  • SimpleDateFormat

Index

Constructors

Properties

The configuration of this widget instance. Please note that no property is guaranteed to be present, you should always check for undefined before accessing a property. This is partly because the value of a property is not transmitted from the server to the client when it equals the default.

Methods

  • format(date: Date): string
  • Format sthe given given according to the pattern of the current widget configuration.

    Parameters

    • date: Date

      A date to format

    Returns string

    The given date as a formatted string.

  • getDayInYear(date: Date): number
  • Computes the ordinal index of the given day in the given year.

    Parameters

    • date: Date

      A day to check.

    Returns number

    The ordinal index of the given day relative to the beginning of the year, starting at 1.

  • getDifference(date1: Date, date2: Date): number
  • Computes the difference between the two given dates.

    Parameters

    • date1: Date

      First input date

    • date2: Date

      Second input date

    Returns number

    Time in milliseconds between the two dates (date1-date2).

  • getMinimalDaysInFirstWeek(days: unknown): number
  • Finds the currently configured value of how many days a week must have at least to be considered a "full" week. Weeks with less that that number of days are disregarded in getWeekInMonth and getWeekInYear.

    Parameters

    • days: unknown

      Unused.

    Returns number

    The minimal number of days a week is allowed to have to be considered a "full" week.

  • Finds closest Sunday preceding the given date. If the date is already a Sunday, that day is returned.

    Parameters

    • date: Date

      Input date.

    Returns Date

    The date at midnight of the first Sunday before the given date. If the given date is already a Sunday, that day is returned.

  • getTimeSince(date1: Date, date2: Date): number
  • Finds the difference in milliseconds between the two given date (date1-date2).

    Parameters

    • date1: Date

      First input date

    • date2: Date

      Second input date

    Returns number

    The numer of milliseconds between the two given date (date1-date2).

  • getUTCTime(date: Date): number
  • Converts the given date to UTC time, that is, the number of milliseconds between midnight, January 1, 1970 Universal Coordinated Time (UTC) (or GMT) and the given date.

    Parameters

    • date: Date

      Date to convert to UTC.

    Returns number

    The given date, converted to UTC time.

  • getWeekInMonth(date: Date, minimalDaysInFirstWeek: number): number
  • Computes the ordinal index of the week of the month of the given date.

    Parameters

    • date: Date

      Date with a month to check.

    • minimalDaysInFirstWeek: number

      Minimal number of days the first week of the month is allowed to have. If the first week contains less days, the returned output is decremented by one (if you do not want to count, say, 2 days, as week).

    Returns number

    The week of the month of the given date, starting at 0.

  • getWeekInYear(date: Date, minimalDaysInFirstWeek: number): number
  • Computes the ordinal index of the week of the year of the given date.

    Parameters

    • date: Date

      Date to check.

    • minimalDaysInFirstWeek: number

      Minimal number of days the first week of the year is allowed to have. If the first week contains less days, the returned output is decremented by one (if you do not want to count, say, 2 days, as week).

    Returns number

    The week of the year of the given date, starting at 0.

  • init(cfg: Partial<TCfg>): void
  • A widget class should not have an explicit constructor. Instead, this initialize method is called after the widget was created. You can use this method to perform any initialization that is required. For widgets that need to create custom HTML on the client-side this is also the place where you should call your render method.

    Parameters

    • cfg: Partial<TCfg>

      The widget configuration to be used for this widget instance. This widget configuration is usually created on the server by the javax.faces.render.Renderer for this component.

    Returns void

  • isBefore(date1: Date, date2: Date): boolean
  • Checks whether the first given date lies before the second given date.

    Parameters

    • date1: Date

      First input date

    • date2: Date

      Second input date

    Returns boolean

    true if date1 lies before date2, or false otherwise.

  • newDateAtMidnight(year: number, month: number, day: number): Date
  • Creates a new date object that represents midnighht of the given year, month, and day.

    Parameters

    • year: number

      A year to set. 0 repesents the year 1900, 100 the year 2000.

    • month: number

      A month (of the year) to set. 0 is January, 11 is December.

    • day: number

      A day (of the month) to set, in the range 1...31.

    Returns Date

    A date for the given year, month, and day at at midnight.

Generated using TypeDoc