Class DateTimeFormat


  • public final class DateTimeFormat
    extends Object
    The object is a constructor for objects that enable language-sensitive date and time formatting.
    See MDN for more details.
    Author:
    Andrea "Stock" Stocchero
    • Constructor Summary

      Constructors 
      Constructor Description
      DateTimeFormat()
      Creates object that enable language sensitive date time formatting, using the default locale.
      DateTimeFormat​(CLocale locale)
      Creates object that enable language sensitive date time formatting, using the locale options.
      DateTimeFormat​(CLocale locale, DateTimeFormatOptions options)
      Creates object that enables language sensitive date time formatting, using the locale options and specific options.
    • Constructor Detail

      • DateTimeFormat

        public DateTimeFormat()
        Creates object that enable language sensitive date time formatting, using the default locale.
      • DateTimeFormat

        public DateTimeFormat​(CLocale locale)
        Creates object that enable language sensitive date time formatting, using the locale options.
        Parameters:
        locale - a locale instance
      • DateTimeFormat

        public DateTimeFormat​(CLocale locale,
                              DateTimeFormatOptions options)
        Creates object that enables language sensitive date time formatting, using the locale options and specific options.
        Parameters:
        locale - a locale instance
        options - options to configure the date time format
    • Method Detail

      • getLocale

        public final CLocale getLocale()
        Returns the locale which has initialized the format.
        Returns:
        the locale which has initialized the format
      • format

        public final String format​(T value)
        Formats a value according to the locale and formatting options of this object.
        Parameters:
        value - the vale to format
        Returns:
        the value in the a string according to the locale and formatting options
      • resolvedOptions

        public final R resolvedOptions()
        Returns a new object with properties reflecting the locale and value formatting options computed during initialization of this object.
        Returns:
        new object with properties reflecting the locale and value formatting options computed during initialization of this object
      • formatToParts

        public final List<FormatPart> formatToParts​(T value)
        Returns an array of objects containing the locale-specific tokens from which it possible to build custom strings while preserving the locale-specific parts.
        It is useful for custom formatting of value strings.
        Parameters:
        value - value to format
        Returns:
        an array of objects containing the formatted value in parts.