Timer.java |
1 /** 2 * QJ-Pro is a static code analyzer for Java. 3 * Copyright (c) 2004, http://qjpro.sourceforge.net 4 * 5 * This program is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License as published by the 7 * Free Software Foundation; either version 2 of the License, or 8 * (at your option) any later version. 9 * 10 * This program is distributed in the hope that it will be useful, but WITHOUT 11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 12 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 13 * details. 14 * 15 * You should have received a copy of the GNU General Public License along with 16 * this program; if not, write to the Free Software Foundation, Inc., 17 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 */ 19 package com.qasystems.debug; 20 21 import java.util.Date; 22 23 /** 24 * DOCUMENT ME! 25 * 26 * @author $author$ 27 * @version $Revision: 1.1 $ 28 */ 29 public class Timer { 30 // fields 31 private Date start = null; 32 private Date stop = null; 33 34 // constructor 35 public Timer() { 36 start = new Date(0); 37 stop = start; 38 } 39 40 // methods 41 public void startTimer() { 42 start = new Date(); 43 } 44 45 /** 46 * DOCUMENT ME! 47 */ 48 public void stopTimer() { 49 stop = new Date(); 50 } 51 52 /** 53 * DOCUMENT ME! 54 * 55 * @return DOCUMENT ME! 56 */ 57 public long getTime() { 58 return (stop.getTime() - start.getTime()); 59 } 60 61 /** 62 * DOCUMENT ME! 63 * 64 * @return DOCUMENT ME! 65 */ 66 public Date getStartTime() { 67 return (start); 68 } 69 70 /** 71 * DOCUMENT ME! 72 * 73 * @return DOCUMENT ME! 74 */ 75 public Date getStopTime() { 76 return (stop); 77 } 78 } 79