Class DateTime

  • All Implemented Interfaces:
    Ippc32, Actionable

    public class DateTime
    extends Task
    Date and time class. This class reads the date and time from the DS1302Z real time clock. The time is updated with a periodic Task.
    This class is a singleton.
    • Method Detail

      • getInstance

        public static DateTime getInstance()
        Get an instance from this class.
        Returns:
        The instance of this class.
      • getSec

        public int getSec()
        Read the actual seconds.
        Returns:
        the actual seconds.
      • getMin

        public int getMin()
        Read the actual minutes.
        Returns:
        the actual minutes.
      • getHour

        public int getHour()
        Reads the actual hour. The hour is represented with the 24 hours format.
        Returns:
        the actual hour.
      • getDate

        public int getDate()
        Reads the actual date of the month.
        Returns:
        the actual date.
      • getMonth

        public int getMonth()
        Reads the actual month.
        Returns:
        the actual month.
      • getYear

        public int getYear()
        Reads the actual year.
        Returns:
        the actual year.
      • setTime

        public void setTime​(int sec,
                            int min,
                            int hour,
                            int date,
                            int month,
                            int year)
        Sets the actual time and writes it to the DS1302Z real time clock.
        Parameters:
        sec - the actual seconds.
        min - the actual minutes.
        hour - the actual hour.
        date - the actual date.
        month - the actual month.
        year - the actual year.
      • getPackedTime

        public int getPackedTime()
        Returns the actual Time as an integer. bits 0 - 4 = seconds / 2 bits 5 - 10 = minutes bits 11 - 15 = hour bits 16 - 20 = date bits 21 - 24 = month bits 25 - 31 = year - 1980
        Returns:
        actual Time as an integer
      • getString

        public int getString​(char[] str)
        Returns the date and time as a string. The format dd.mm.yyyy hh:mm:ss.
        Parameters:
        str - date and time as string
        Returns:
        The length of the string