how to count the seconds in java?
<p>I'm trying to understand how I could go about keeping track of the seconds that an object has been created for.</p>

<p>The program I'm working on with simulates a grocery store. </p>

<p>Some of the foods posses the trait to spoil after a set amount of time and this is all done in a subclass of an <code>item</code> class called <code>groceryItem</code>. The seconds do not need to be printed but are kept track of using a <code>currentTime</code> field and I don't quite understand how to count the seconds exactly.</p>

<p>I was looking at using the Java.util.Timer or the Java.util.Date library maybe but I don't fully understand how to use them for my issue.</p>

<p>I don't really have a very good understanding of java but any help would be appreciated.</p>