Interface DateParser

  • All Known Implementing Classes:
    FastDateFormat, FastDateParser

    public interface DateParser

    DateParser is the "missing" interface for the parsing methods of DateFormat.

    Since:
    3.2
    • Method Summary

      Modifier and Type Method Description
      java.util.Locale getLocale()
      Get the locale used by this parser.
      java.lang.String getPattern()
      Get the pattern used by this parser.
      java.util.TimeZone getTimeZone()
      Get the time zone used by this parser.
      java.util.Date parse​(java.lang.String source)
      Equivalent to DateFormat.parse(String).
      java.util.Date parse​(java.lang.String source, java.text.ParsePosition pos)
      Equivalent to DateFormat.parse(String, ParsePosition).
      java.lang.Object parseObject​(java.lang.String source)
      Parses text from a string to produce a Date.
      java.lang.Object parseObject​(java.lang.String source, java.text.ParsePosition pos)
      Parse a date/time string according to the given parse position.
    • Method Detail

      • parse

        java.util.Date parse​(java.lang.String source)
                      throws java.text.ParseException
        Equivalent to DateFormat.parse(String). See DateFormat.parse(String) for more information.
        Parameters:
        source - A String whose beginning should be parsed.
        Returns:
        A Date parsed from the string
        Throws:
        java.text.ParseException - if the beginning of the specified string cannot be parsed.
      • parse

        java.util.Date parse​(java.lang.String source,
                             java.text.ParsePosition pos)
        Equivalent to DateFormat.parse(String, ParsePosition). See DateFormat.parse(String, ParsePosition) for more information.
        Parameters:
        source - A String, part of which should be parsed.
        pos - A ParsePosition object with index and error index information as described above.
        Returns:
        A Date parsed from the string. In case of error, returns null.
        Throws:
        java.lang.NullPointerException - if text or pos is null.
      • getPattern

        java.lang.String getPattern()

        Get the pattern used by this parser.

        Returns:
        the pattern, SimpleDateFormat compatible
      • getTimeZone

        java.util.TimeZone getTimeZone()

        Get the time zone used by this parser.

        The default TimeZone used to create a Date when the TimeZone is not specified by the format pattern.

        Returns:
        the time zone
      • getLocale

        java.util.Locale getLocale()

        Get the locale used by this parser.

        Returns:
        the locale
      • parseObject

        java.lang.Object parseObject​(java.lang.String source)
                              throws java.text.ParseException
        Parses text from a string to produce a Date.
        Parameters:
        source - A String whose beginning should be parsed.
        Returns:
        a java.util.Date object
        Throws:
        java.text.ParseException - if the beginning of the specified string cannot be parsed.
        See Also:
        Format.parseObject(String)
      • parseObject

        java.lang.Object parseObject​(java.lang.String source,
                                     java.text.ParsePosition pos)
        Parse a date/time string according to the given parse position.
        Parameters:
        source - A String whose beginning should be parsed.
        pos - the parse position
        Returns:
        a java.util.Date object
        See Also:
        DateFormat.parseObject(String, ParsePosition)