How do I measure time elapsed in Java? [duplicate]

I want to have something like this:

public class Stream
{
    public startTime;
    public endTime;

    public getDuration()
    {
        return startTime - endTime;
    }
}

Also it is important that for example if the startTime it’s 23:00 and endTime 1:00 to get a duration of 2:00.

Which types to use in order to accomplish this in Java?

15 Answers
15

Leave a Comment