KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > tomcat > jni > Time


1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one or more
3  * contributor license agreements. See the NOTICE file distributed with
4  * this work for additional information regarding copyright ownership.
5  * The ASF licenses this file to You under the Apache License, Version 2.0
6  * (the "License"); you may not use this file except in compliance with
7  * the License. You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */

17
18 package org.apache.tomcat.jni;
19
20 /** Time
21  *
22  * @author Mladen Turk
23  * @version $Revision: 467222 $, $Date: 2006-10-24 05:17:11 +0200 (mar., 24 oct. 2006) $
24  */

25
26 public class Time {
27
28     /** number of microseconds per second */
29     public static final long APR_USEC_PER_SEC = 1000000L;
30     /** number of miliseconds per microsecond */
31     public static final long APR_MSEC_PER_USEC = 1000L;
32
33     /** @return apr_time_t as a second */
34     public static long sec(long t)
35     {
36         return t / APR_USEC_PER_SEC;
37     }
38
39     /** @return apr_time_t as a msec */
40     public static long msec(long t)
41     {
42         return t / APR_MSEC_PER_USEC;
43     }
44
45     /**
46      * number of microseconds since 00:00:00 january 1, 1970 UTC
47      * @return the current time
48      */

49     public static native long now();
50
51     /**
52      * Formats dates in the RFC822
53      * format in an efficient manner.
54      * @param t the time to convert
55      */

56     public static native String JavaDoc rfc822(long t);
57
58     /**
59      * Formats dates in the ctime() format
60      * in an efficient manner.
61      * Unlike ANSI/ISO C ctime(), apr_ctime() does not include
62      * a \n at the end of the string.
63      * @param t the time to convert
64      */

65     public static native String JavaDoc ctime(long t);
66
67     /**
68      * Sleep for the specified number of micro-seconds.
69      * <br /><b>Warning :</b> May sleep for longer than the specified time.
70      * @param t desired amount of time to sleep.
71      */

72     public static native void sleep(long t);
73
74 }
75
Popular Tags