Class YMDDateFormatter

  • All Implemented Interfaces:
    DateFormatter

    public class YMDDateFormatter
    extends Object
    implements DateFormatter
    A DateFormatter that formats the requested date fields.
    • Constructor Detail

      • YMDDateFormatter

        public YMDDateFormatter​(String requestedFields)
        Creates a new formatter that formats the requested fields. The formatter defaults to the current locale and time zone.
        Parameters:
        requestedFields - the requested fields
      • YMDDateFormatter

        public YMDDateFormatter​(String requestedFields,
                                String localeName,
                                TimeZone timeZone)
        Creates a new formatter that formats the requested fields using the provided locale and time zone.
        Parameters:
        requestedFields - the requested fields
        localeName - the locale to use
        timeZone - the time zone to use
    • Method Detail

      • format

        public String format​(long date)
        Returns a string representing the formatted date.
        Specified by:
        format in interface DateFormatter
        Parameters:
        date - the date in milliseconds
        Returns:
        the formatted time
      • format

        public String format​(Date date)
        Returns a string representing the formatted date.
        Specified by:
        format in interface DateFormatter
        Parameters:
        date - the date
        Returns:
        the formatted time
      • withLocale

        public DateFormatter withLocale​(String locName)
        Returns a version of this formatter customized to the provided locale.
        Specified by:
        withLocale in interface DateFormatter
        Returns:
        a new formatter for the given locale
      • withTimeZone

        public DateFormatter withTimeZone​(TimeZone tz)
        Returns a version of this formatter customized to the provided time zone.
        Specified by:
        withTimeZone in interface DateFormatter
        Parameters:
        tz - the new time zone
        Returns:
        a new formatter for the given time zone