views:

42

answers:

1

What is the appropriate way to set a duration in Java with standard Java libs? Date()? Calendar()? Example?

Thanks & Cheers ER

+3  A: 

There is a de-facto standard for Java Date & time - JodaTime. It has Duration. The JodaTime API is considered far better than Date and Calendar.

Of course, you can also store the duration in a long - the milliseconds.

Bozho
Thanks, I knew about Joda, however, I would like to know how a duration would be represented with standard libraries ...
O ... that "long" is what I like much more. I just want to make sure that this would be best practice with standard libs. long, or even int, would be great!