Class Duration

  • All Implemented Interfaces:
    Serializable

    public class Duration
    extends Object
    implements Serializable
    An encapsulation of the duration of a podcast. This will serialize (via .toString()) to HH:MM:SS format, and can parse [H]*H:[M]*M:[S]*S or [M]*M:[S]*S.
    See Also:
    Serialized Form
    • Constructor Detail

      • Duration

        public Duration()
        Creates a new Duration object with 0 length.
      • Duration

        public Duration​(long milliseconds)
        Creates a new instance of Duration specifying a length in milliseconds
        Parameters:
        milliseconds - Creates a new instance of Duration specifying a length in milliseconds
      • Duration

        public Duration​(int hours,
                        int minutes,
                        float seconds)
        Creates a new duration object with the given hours, minutes and seconds
        Parameters:
        hours - number of hours
        minutes - number of minutes
        seconds - number of seconds
      • Duration

        public Duration​(String duration)
        Creates a new Duration parsing the String value.
        Parameters:
        duration - A String to parse
    • Method Detail

      • toString

        public String toString()
        Returns a String representation in the formation HH:MM:SS
        Overrides:
        toString in class Object
        Returns:
        Returns a String representation in the formation HH:MM:SS
      • getMilliseconds

        public long getMilliseconds()
        Returns the millisecond length
        Returns:
        the millisecond length
      • setMilliseconds

        public void setMilliseconds​(long milliseconds)
        Sets the millisecond length
        Parameters:
        milliseconds - the millisecond length