You use the classes Date and Duration:
http://download.oracle.com/javase/1.5.0/docs/api/java/util/Date.html
http://download.oracle.com/javase/1.5.0/docs/api/javax/xml/datatype/Duration.html
You create Date-objects, then use Duration's methods addTo() and subtract()