| | |
| | | * CDDL HEADER END |
| | | * |
| | | * |
| | | * Portions Copyright 2006-2007 Sun Microsystems, Inc. |
| | | * Portions Copyright 2006-2008 Sun Microsystems, Inc. |
| | | */ |
| | | package org.opends.server.util; |
| | | |
| | |
| | | // The current time in milliseconds since the epoch. |
| | | private static volatile long time; |
| | | |
| | | // The current time in nanoseconds. |
| | | private static volatile long nanoTime; |
| | | |
| | | // The date formatter that will be used to obtain the generalized time. |
| | | private static SimpleDateFormat generalizedTimeFormatter; |
| | | |
| | |
| | | calendar = new GregorianCalendar(); |
| | | date = calendar.getTime(); |
| | | time = date.getTime(); |
| | | nanoTime = System.nanoTime(); |
| | | generalizedTime = generalizedTimeFormatter.format(date); |
| | | localTimestamp = localTimestampFormatter.format(date); |
| | | gmtTimestamp = gmtTimestampFormatter.format(date); |
| | |
| | | calendar = new GregorianCalendar(); |
| | | date = calendar.getTime(); |
| | | time = date.getTime(); |
| | | nanoTime = System.nanoTime(); |
| | | generalizedTime = generalizedTimeFormatter.format(date); |
| | | localTimestamp = localTimestampFormatter.format(date); |
| | | gmtTimestamp = gmtTimestampFormatter.format(date); |
| | |
| | | return time; |
| | | } |
| | | |
| | | /** |
| | | * Retrieves the time in nanoseconds from the most precise available system |
| | | * timer. The value retured represents nanoseconds since some fixed but |
| | | * arbitrary time. |
| | | * |
| | | * @return The time in nanoseconds from some fixed but arbitrary time. |
| | | */ |
| | | public static long getNanoTime() |
| | | { |
| | | return nanoTime; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |