01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * 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: return t / APR_USEC_PER_SEC;
36: }
37:
38: /** @return apr_time_t as a msec */
39: public static long msec(long t) {
40: return t / APR_MSEC_PER_USEC;
41: }
42:
43: /**
44: * number of microseconds since 00:00:00 january 1, 1970 UTC
45: * @return the current time
46: */
47: public static native long now();
48:
49: /**
50: * Formats dates in the RFC822
51: * format in an efficient manner.
52: * @param t the time to convert
53: */
54: public static native String rfc822(long t);
55:
56: /**
57: * Formats dates in the ctime() format
58: * in an efficient manner.
59: * Unlike ANSI/ISO C ctime(), apr_ctime() does not include
60: * a \n at the end of the string.
61: * @param t the time to convert
62: */
63: public static native String ctime(long t);
64:
65: /**
66: * Sleep for the specified number of micro-seconds.
67: * <br /><b>Warning :</b> May sleep for longer than the specified time.
68: * @param t desired amount of time to sleep.
69: */
70: public static native void sleep(long t);
71:
72: }
|