Class OraSimpleDateFormat

  • All Implemented Interfaces:
    Serializable, Cloneable

    public class OraSimpleDateFormat
    extends OraDateFormat
    The OraSimpleDateFormat class is a concrete class to do locale-sensitive formatting and parsing between date/time and string. It supports Oracle date/time formatting behavior.
    See Also:
    OraDateFormat, Serialized Form
    • Constructor Detail

      • OraSimpleDateFormat

        public OraSimpleDateFormat()
        Deprecated.
        As of Oracle Database 10g Release 2 (10.2), replaced by OraSimpleDateFormat(String, Locale)
        Constructs an OraSimpleDateFormat object that uses the default date/time formatting sytle for the default locale.
      • OraSimpleDateFormat

        public OraSimpleDateFormat​(String pattern)
                            throws ParseException
        Deprecated.
        As of Oracle Database 10g Release 2 (10.2), replaced by OraSimpleDateFormat(String, Locale)
        Constructs an OraSimpleDateFormat object that uses the given format pattern for the default locale.
        Parameters:
        pattern - the given format pattern
        Throws:
        ParseException - if the format pattern is invalid
      • OraSimpleDateFormat

        public OraSimpleDateFormat​(String pattern,
                                   Locale locale)
                            throws ParseException
        Constructs an OraSimpleDateFormat object that uses the given format pattern for the given locale.
        Parameters:
        pattern - the given format pattern
        locale - the given locale
        Throws:
        ParseException - if the format pattern is invalid
      • OraSimpleDateFormat

        public OraSimpleDateFormat​(String pattern,
                                   OraLocaleInfo localeInfo)
                            throws ParseException
        Constructs an OraSimpleDateFormat object that uses the given format pattern for the given OraLocaleInfo object.
        Parameters:
        pattern - the given format pattern
        localeInfo - the given OraLocaleInfo object
        Throws:
        ParseException - if the format pattern is invalid
      • OraSimpleDateFormat

        public OraSimpleDateFormat​(String pattern,
                                   OraDateFormatSymbols symbols,
                                   Locale locale)
                            throws ParseException
        Constructs an OraSimpleDateFormat object that uses the given format pattern and the given Oracle date/time symbols for the given locale.
        Parameters:
        pattern - the given format pattern
        symbols - the given Oracle date/time symbols
        locale - the given locale
        Throws:
        ParseException - if the format pattern is invalid
      • OraSimpleDateFormat

        public OraSimpleDateFormat​(String pattern,
                                   OraDateFormatSymbols symbols,
                                   OraLocaleInfo localeInfo)
                            throws ParseException
        Constructs an OraSimpleDateFormat object that uses the given format pattern and the given Oracle date/time symbols for the given OraLocaleInfo object.
        Parameters:
        pattern - the given format pattern
        symbols - the given Oracle date/time symbols
        localeInfo - the given OraLocaleInfo object
        Throws:
        ParseException - if the format pattern is invalid
    • Method Detail

      • applyPattern

        public void applyPattern​(String pattern)
                          throws ParseException
        Applies the given format pattern of this date/time formatter.
        Parameters:
        pattern - the given format pattern
        Throws:
        ParseException - if the format pattern is invalid
      • format

        public StringBuffer format​(Date date,
                                   StringBuffer toAppendTo,
                                   FieldPosition pos)
        Formats a Date object into a date/time string. Sets field position if needed.
        Specified by:
        format in class OraDateFormat
        Parameters:
        date - the date/time object to be formatted.
        toAppendTo - the string buffer to be appended with the formatted date/time string.
        pos - to be used to get offsets of a given field in the returned string buffer. On input, the alignment field of which the offsets are to be returned. On output, the offsets of the alignment field in the returned string buffer.
        Returns:
        the string buffer appended with the formatted date/time string
        Throws:
        IllegalArgumentException - if any error occurs in the format operation
      • getOraDateFormatSymbols

        public OraDateFormatSymbols getOraDateFormatSymbols()
        Returns the Oracle date/time format symbols or translations used in this formatter. The symbols include: month names, abbreviated month names, names of day-of-the-week, abbreviated names of day-of-the-week, era strings, and meridian indicators.
        Returns:
        an OracleDateFormatSymbols object
        See Also:
        OraDateFormatSymbols
      • setOraDateFormatSymbols

        public void setOraDateFormatSymbols​(OraDateFormatSymbols sym)
        Sets the Oracle date/time format symbols or translations to the given OraDateFormatSymbols object for this formatter.
        Parameters:
        sym - the given OraDateFormatSymbols object
      • parse

        public Date parse​(String text,
                          ParsePosition pos)
        Parses a date/time string into a Date object, starting from the given parse position.
        Specified by:
        parse in class OraDateFormat
        Parameters:
        text - the date/time string
        pos - indicates where to start the parsing on input. On output, returns where the parse ends if parsing succeeds, or the start index if it fails.
        Returns:
        a Date object
        Throws:
        IllegalArgumentException - if the format pattern associated with this formatter is not valid for parsing or the given date/time string cannot be parsed into a Date object
      • toPattern

        public String toPattern()
        Returns the format pattern associated with this date/time formatter.
        Returns:
        a format pattern string
      • getLocale

        public Locale getLocale()
        Returns the locale associated with this date/time formatter.
        Returns:
        a Java Locale object
      • clone

        public Object clone()
        Overrides the clone method.
        Overrides:
        clone in class OraDateFormat
        Returns:
        a cloned object
      • equals

        public boolean equals​(Object object)
        Overrides the equals method.
        Overrides:
        equals in class OraDateFormat
        Parameters:
        object - an object to be compared
        Returns:
        true if two objects are identical, otherwise false
      • hashCode

        public int hashCode()
        Overrides the hashCode method.
        Overrides:
        hashCode in class Object
        Returns:
        a hash value