KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jahia > utils > JahiaChrono


1 //
2
// JahiaChrono
3
// EV 23.12.2000
4
//
5
// getInstance()
6
// start()
7
// read( startTime )
8
// toConsole( startTime, message )
9
//
10

11 package org.jahia.utils;
12
13 import java.util.Date JavaDoc;
14
15 public class JahiaChrono
16 {
17     
18     private static JahiaChrono theObject = null;
19     
20
21     /***
22         * constructor
23         * EV 23.12.2000
24         *
25         */

26     private JahiaChrono()
27     {
28         JahiaConsole.println( "JahiaChrono", "Starting JahiaChrono utils" );
29     } // end constructor
30

31
32
33     /***
34         * getInstance
35         * EV 23.12.2000
36         *
37         */

38     public static JahiaChrono getInstance()
39     {
40         if (theObject == null) {
41             theObject = new JahiaChrono();
42         }
43         return theObject;
44     } // end getInstance
45

46
47
48     /***
49         * start
50         * EV 23.12.2000
51         *
52         */

53     public long start()
54     {
55         return (new Date JavaDoc()).getTime();
56     } // end start
57

58
59
60     /***
61         * read
62         * EV 23.12.2000
63         *
64         */

65     public long read( long startTime )
66     {
67         return ((new Date JavaDoc()).getTime() - startTime);
68     } // end read
69

70
71
72     /***
73         * toConsole
74         * EV 23.12.2000
75         *
76         */

77     public void toConsole( long startTime, String JavaDoc message )
78     {
79         JahiaConsole.println( "JahiaChrono", "[" + read(startTime) + "ms] " + message );
80     } // end toConsole
81

82
83 } // end JahiaChrono
Popular Tags