Version 3.6.0.4, tag libreoffice-3.6.0.4
[LibreOffice.git] / qadevOOo / runner / graphical / TimeHelper.java
blob057f9cd19494b505d54c76e17ef71b877e56c6ff
1 /*
2 * ************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 * ***********************************************************************
30 package graphical;
32 import java.util.Calendar;
34 /**
36 * @author ll93751
38 public class TimeHelper
41 wait a second the caller don't need to handle the interruptexception
42 @param _nSeconds how long should we wait
43 @param _sReason give a good reason, why we have to wait
45 static void waitInSeconds(int _nSeconds, String _sReason)
47 GlobalLogWriter.println("Wait 0.25 * " + String.valueOf(_nSeconds) + " sec. Reason: " + _sReason);
48 try {
49 java.lang.Thread.sleep(_nSeconds * 250);
50 } catch (java.lang.InterruptedException e2) {}
53 private int m_nSeconds;
54 private int m_nMilliSeconds;
55 private long m_nRealMilliSeconds;
57 private boolean m_bIsStopped = false;
59 public TimeHelper()
62 public void start()
64 m_bIsStopped = false;
65 Calendar cal = Calendar.getInstance();
66 m_nSeconds = cal.get(Calendar.SECOND);
67 m_nMilliSeconds = cal.get(Calendar.MILLISECOND);
69 public void stop()
71 Calendar cal = Calendar.getInstance();
72 m_bIsStopped = true;
73 int nSeconds = cal.get(Calendar.SECOND);
74 m_nSeconds = nSeconds - m_nSeconds;
75 if (m_nSeconds < 0)
77 // add a minute
78 m_nSeconds += 60;
81 int nMilliSeconds = cal.get(Calendar.MILLISECOND);
82 m_nMilliSeconds = nMilliSeconds - m_nMilliSeconds;
83 m_nRealMilliSeconds = m_nSeconds * 1000 + m_nMilliSeconds;
86 public String getTime()
88 return String.valueOf(m_nRealMilliSeconds);