Package smile.data

Class DateAttribute

  • All Implemented Interfaces:
    java.io.Serializable

    public class DateAttribute
    extends Attribute
    Data attribute. The default format string accepts the ISO-8601 combined date and time format: "yyyy-MM-dd'T'HH:mm:ss".
    Author:
    Haifeng Li
    See Also:
    Serialized Form
    • Constructor Summary

      Constructors 
      Constructor Description
      DateAttribute​(java.lang.String name)
      Constructor.
      DateAttribute​(java.lang.String name, double weight)
      Constructor.
      DateAttribute​(java.lang.String name, java.lang.String description, double weight)
      Constructor.
      DateAttribute​(java.lang.String name, java.lang.String description, double weight, java.lang.String format)
      Constructor.
      DateAttribute​(java.lang.String name, java.lang.String description, java.lang.String format)
      Constructor.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.text.DateFormat getFormat()
      Returns the date string formatter.
      void setFormat​(java.lang.String format)
      Sets the date format.
      void setFormat​(java.text.DateFormat format)
      Sets the date string formatter.
      java.util.Date toDate​(double x)
      Retruns the date object from internal double encoding.
      java.lang.String toString​(double x)
      Returns the string representation of a double value of this attribute.
      java.lang.String toString​(java.util.Date date)
      Generate the date string.
      double valueOf​(java.lang.String s)
      Returns the double value of a string of this attribute.
      double valueOf​(java.util.Date date)
      Returns the double value representation of a data object.
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • DateAttribute

        public DateAttribute​(java.lang.String name)
        Constructor.
      • DateAttribute

        public DateAttribute​(java.lang.String name,
                             double weight)
        Constructor.
      • DateAttribute

        public DateAttribute​(java.lang.String name,
                             java.lang.String description,
                             double weight)
        Constructor.
      • DateAttribute

        public DateAttribute​(java.lang.String name,
                             java.lang.String description,
                             java.lang.String format)
        Constructor.
        Parameters:
        name - the name of attribute.
        format - the date format.
      • DateAttribute

        public DateAttribute​(java.lang.String name,
                             java.lang.String description,
                             double weight,
                             java.lang.String format)
        Constructor.
        Parameters:
        name - the name of attribute.
        format - the date format.
    • Method Detail

      • getFormat

        public java.text.DateFormat getFormat()
        Returns the date string formatter.
        Returns:
        the date string formatter.
      • setFormat

        public void setFormat​(java.lang.String format)
        Sets the date format.
        Parameters:
        format - the date format string.
      • setFormat

        public void setFormat​(java.text.DateFormat format)
        Sets the date string formatter.
        Parameters:
        format - the date string formatter.
      • toString

        public java.lang.String toString​(java.util.Date date)
        Generate the date string.
      • toDate

        public java.util.Date toDate​(double x)
        Retruns the date object from internal double encoding.
        Parameters:
        x - the date in double encoding.
      • valueOf

        public double valueOf​(java.util.Date date)
        Returns the double value representation of a data object.
      • toString

        public java.lang.String toString​(double x)
        Description copied from class: Attribute
        Returns the string representation of a double value of this attribute.
        Specified by:
        toString in class Attribute
        Parameters:
        x - a double value of this attribute. NaN means missing value.
        Returns:
        the string representation of x. For nominal, date and string attributes, null will be returned for missing values. For numeric attributes, "NaN" will be returned for missing values.
      • valueOf

        public double valueOf​(java.lang.String s)
                       throws java.text.ParseException
        Description copied from class: Attribute
        Returns the double value of a string of this attribute.
        Specified by:
        valueOf in class Attribute
        Parameters:
        s - a string value of this attribute.
        Throws:
        java.text.ParseException