All Downloads are FREE. Search and download functionalities are using the official Maven repository.

javax.media.Time Maven / Gradle / Ivy

The newest version!
package javax.media;

/**
 * Standard JMF class -- see this class in the JMF Javadoc.
 *
 * Complete.
 *
 * @author Ken Larson
 *
 */
public class Time implements java.io.Serializable
{
    public static final long ONE_SECOND = 1000000000;

    public static final Time TIME_UNKNOWN = new Time(Long.MAX_VALUE - 1);

    private static final double NANO_TO_SEC = 1E-9;

    protected long nanoseconds;

    static
    { // for Serializable compatibility.
    }

    public Time(double seconds)
    {
        this.nanoseconds = secondsToNanoseconds(seconds);
    }

    public Time(long nanoseconds)
    {
        this.nanoseconds = nanoseconds;
    }

    public long getNanoseconds()
    {
        return nanoseconds;
    }

    public double getSeconds()
    {
        return nanoseconds * NANO_TO_SEC;
    }

    protected long secondsToNanoseconds(double seconds)
    {
        return (long) (seconds * ONE_SECOND);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy