- java.lang.Object
-
- de.ibapl.jnhw.posix.Time
-
@Include("#include <time.h>") public class Time extends Object
Wrapper around the<time.h>header. See specs at: time.h - time types.- Author:
- aploese
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classTime.ItimerspecPOSIX:structure itimerspec.static classTime.Timer_tPOSIX:typedef pthread_t.static classTime.TimespecPOSIX:structure timespec.static classTime.TmPOSIX:structure tm.
-
Field Summary
Fields Modifier and Type Field Description static intCLOCK_MONOTONICPOSIX: The identifier for the system-wide monotonic clock, which is defined as a clock measuring real time, whose value cannot be set via clock_settime() and which cannot have negative clock jumps.The maximum possible clock jump shall be implementation-defined..static intCLOCK_PROCESS_CPUTIME_IDPOSIX: The identifier of the CPU-time clock associated with the process making a clock() or timer*() function call..static intCLOCK_REALTIMEPOSIX: The identifier of the system-wide clock measuring real time.static intCLOCK_THREAD_CPUTIME_IDPOSIX: The identifier of the CPU-time clock associated with the thread making a clock() or timer*() function call..static intCLOCKS_PER_SECPOSIX: A number used to convert the value returned by the clock() function into seconds.static booleanHAVE_TIME_Hstatic intTIMER_ABSTIMEPOSIX: Flag indicating time is absolute.For functions taking timer objects, this refers to the clock associated with the timer.
-
Constructor Summary
Constructors Constructor Description Time()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static Stringasctime(Time.Tm tm)static Stringasctime_r(Time.Tm tm, OpaqueMemory32 buf)static longclock()POSIX: clock - report CPU time used.static voidclock_getcpuclockid(int pid, IntRef clock_id)static voidclock_getres(int clock_id, Time.Timespec timespec)POSIX: clock_getres, clock_gettime, clock_settime - clock and timer functions.The clock_getres() function shall return the resolution of any clock.static voidclock_gettime(int clock_id, Time.Timespec timespec)POSIX: clock_getres, clock_gettime, clock_settime - clock and timer functions.The clock_gettime() function shall return the current value tp for the specified clock, clock_id.static voidclock_nanosleep(int clock_id, int flags, Time.Timespec rqtp, Time.Timespec rmtp)static voidclock_settime(int clock_id, Time.Timespec timespec)POSIX: clock_getres, clock_gettime, clock_settime - clock and timer functions.The clock_settime() function shall set the specified clock, clock_id, to the value specified by tp.static Stringctime(long clock)static Stringctime_r(long clock, OpaqueMemory32 buf)static intdaylight()static doubledifftime(long time1, long time0)static Time.Tmgetdate(String string)static Time.Tmgmtime(long timer)static Time.Tmgmtime_r(long timer, Time.Tm result)static Time.Tmlocaltime(long timer)static Time.Tmlocaltime_r(long timer, Time.Tm result)POSIX: poll - input/output multiplexing.static longmktime(Time.Tm timeptr)static voidnanosleep(Time.Timespec rqtp, Time.Timespec rmtp)static Stringstrftime(long maxsize, String format, Time.Tm timeptr)static Stringstrftime_l(long maxsize, String format, Time.Tm timeptr, Locale.Locale_t locale)static Stringstrptime(String buf, String format, Time.Tm tm)static longtime(LongRef tloc)POSIX: time - get time.static voidtimer_create(int clockid, Signal.Sigevent evp, Time.Timer_t timerid)static voidtimer_delete(Time.Timer_t timerid)static inttimer_getoverrun(Time.Timer_t timerid)static voidtimer_gettime(Time.Timer_t timerid, Time.Itimerspec value)static voidtimer_settime(Time.Timer_t timerid, int flags, Time.Itimerspec value, Time.Itimerspec ovalue)static longtimezone()static String[]tzname()static voidtzset()
-
-
-
Field Detail
-
CLOCKS_PER_SEC
@Define public static final int CLOCKS_PER_SEC
POSIX: A number used to convert the value returned by the clock() function into seconds. The value shall be an expression with type clock_t. [XSI] [Option Start] The value of CLOCKS_PER_SEC shall be 1 million on XSI-conformant systems. However, it may be variable on other systems, and it should not be assumed that CLOCKS_PER_SEC is a compile-time constant. .
-
CLOCK_MONOTONIC
@Define public static final int CLOCK_MONOTONIC
POSIX: The identifier for the system-wide monotonic clock, which is defined as a clock measuring real time, whose value cannot be set via clock_settime() and which cannot have negative clock jumps.The maximum possible clock jump shall be implementation-defined..
-
CLOCK_PROCESS_CPUTIME_ID
@Define public static final int CLOCK_PROCESS_CPUTIME_ID
POSIX: The identifier of the CPU-time clock associated with the process making a clock() or timer*() function call..
-
CLOCK_REALTIME
@Define public static final int CLOCK_REALTIME
POSIX: The identifier of the system-wide clock measuring real time.
-
CLOCK_THREAD_CPUTIME_ID
@Define public static final int CLOCK_THREAD_CPUTIME_ID
POSIX: The identifier of the CPU-time clock associated with the thread making a clock() or timer*() function call..
-
HAVE_TIME_H
public static final boolean HAVE_TIME_H
-
TIMER_ABSTIME
@Define public static final int TIMER_ABSTIME
POSIX: Flag indicating time is absolute.For functions taking timer objects, this refers to the clock associated with the timer.
-
-
Method Detail
-
asctime
public static final String asctime(Time.Tm tm)
- Parameters:
tm- the time to convert.- Returns:
- on succes the converted date and time, otherwise
null
-
asctime_r
public static final String asctime_r(Time.Tm tm, OpaqueMemory32 buf)
- Parameters:
tm- the time to convert.buf- buffer to place the converted time string too. Must be at least 26 bytes long.- Returns:
- on succes the converted date and time, otherwise
null
-
clock
public static final long clock()
POSIX: clock - report CPU time used.- Returns:
- the processor time used by the process.
-
clock_getcpuclockid
public static final void clock_getcpuclockid(int pid, IntRef clock_id) throws NativeErrorException- Parameters:
pid- the pid to get the cpu time of. If zero the pid of the calling process is used.clock_id- the clock ID of the pid will be placed here.- Throws:
NullPointerException- if clock_id isnullNativeErrorException- if the return value of the native function indicates an error.
-
clock_getres
public static final void clock_getres(int clock_id, Time.Timespec timespec) throws NativeErrorExceptionPOSIX: clock_getres, clock_gettime, clock_settime - clock and timer functions.The clock_getres() function shall return the resolution of any clock.- Parameters:
clock_id- the ID of the clock to use.timespec- if notnullthe timespec of clock_is is returned.- Throws:
NativeErrorException- if the return value of the native function indicates an error.
-
clock_gettime
public static final void clock_gettime(int clock_id, Time.Timespec timespec) throws NativeErrorExceptionPOSIX: clock_getres, clock_gettime, clock_settime - clock and timer functions.The clock_gettime() function shall return the current value tp for the specified clock, clock_id.- Parameters:
clock_id- the ID of the clock to use.timespec- the timespect to get.- Throws:
NativeErrorException- if the return value of the native function indicates an error.
-
clock_nanosleep
public static final void clock_nanosleep(int clock_id, int flags, Time.Timespec rqtp, Time.Timespec rmtp) throws NativeErrorException, NoSuchNativeMethodException- Parameters:
clock_id- the ID of the clock to use.flags- the flags arguent.rqtp- the time to wait.rmtp- if notnullthe remaining time, if interruped.- Throws:
NativeErrorException- if the return value of the native function indicates an error.NoSuchNativeMethodException- if the method clock_nanosleep is not available natively.
-
clock_settime
public static final void clock_settime(int clock_id, Time.Timespec timespec) throws NativeErrorExceptionPOSIX: clock_getres, clock_gettime, clock_settime - clock and timer functions.The clock_settime() function shall set the specified clock, clock_id, to the value specified by tp.- Parameters:
clock_id- the ID of the clock to use.timespec- the timespec to set.- Throws:
NativeErrorException- if the return value of the native function indicates an error.
-
ctime
public static final String ctime(long clock)
- Parameters:
clock- the time to convert.- Returns:
- on succes the converted time, otherwise
null
-
ctime_r
public static final String ctime_r(long clock, OpaqueMemory32 buf)
- Parameters:
clock- the time to convert.buf- buffer to place the converted time string too. Must be at least 26 bytes long.- Returns:
- on succes the converted time, otherwise
null
-
daylight
public static final int daylight() throws NoSuchNativeMethodException- Returns:
- the native value of daylight.
- Throws:
NoSuchNativeMethodException- if the method daylight is not available natively.
-
difftime
public static final double difftime(long time1, long time0)- Parameters:
time1-time0-- Returns:
- time1 - time0 expressed in seconds as a type double.
-
getdate
public static final Time.Tm getdate(String string) throws NativeErrorException, NoSuchNativeMethodException
- Parameters:
string- the string to convert.- Returns:
- Upon successful completion, a pointer to a struct tm.
- Throws:
NativeErrorException- returns the getdate_err error codes.NoSuchNativeMethodException- if the method getdate is not available natively.
-
gmtime
public static final Time.Tm gmtime(long timer)
- Parameters:
timer- time in seconds since the Epoch- Returns:
-
gmtime_r
public static final Time.Tm gmtime_r(long timer, Time.Tm result) throws NativeErrorException
- Parameters:
timer- time in seconds since the Epochresult- a sruct tm (Time.Tm) to hold the result.- Returns:
- on successful completion,
result. - Throws:
NativeErrorException- if the return value of the native function indicates an error.
-
localtime
public static final Time.Tm localtime(long timer) throws NativeErrorException
- Parameters:
timer- the time in seconds since the Epoch.- Returns:
- on successful completion, a pointer to the broken-down time structure.
- Throws:
NativeErrorException- if the return value of the native function indicates an error.
-
localtime_r
public static final Time.Tm localtime_r(long timer, Time.Tm result) throws NativeErrorException
POSIX: poll - input/output multiplexing.- Parameters:
timer- the time in seconds since the Epoch.result- a sruct tm (Time.Tm) to hold the result.- Returns:
- on successful completion, a pointer to the broken-down time
structure
result. - Throws:
NativeErrorException- if the return value of the native function indicates an error.
-
mktime
public static final long mktime(Time.Tm timeptr) throws NativeErrorException
- Parameters:
timeptr- the time since the epoch in aTmstructure.- Returns:
- the time in seconds since the Epoch
- Throws:
NativeErrorException- if the return value of the native function indicates an error.
-
nanosleep
public static final void nanosleep(Time.Timespec rqtp, Time.Timespec rmtp) throws NativeErrorException
- Parameters:
rqtp- the time to sleeprmtp- if notnullthe remaining time.- Throws:
NativeErrorException- if the requested time has not elapsed.
-
strftime
public static final String strftime(long maxsize, String format, Time.Tm timeptr)
- Parameters:
maxsize- the max size of the buffer.format- a format string.timeptr- the time.- Returns:
- on succes the converted time otherwise
null.
-
strftime_l
public static final String strftime_l(long maxsize, String format, Time.Tm timeptr, Locale.Locale_t locale)
- Parameters:
maxsize- the max size of the buffer.format- a format string.timeptr- the time.locale- the locale to use.- Returns:
- on succes the converted time otherwise
null.
-
strptime
public static final String strptime(String buf, String format, Time.Tm tm)
- Parameters:
buf- the character string to convertformat- the format to usetm- the target of the conversation.- Returns:
- the index of the character in
buf, following the last character parsed.
-
time
public static final long time(LongRef tloc) throws NativeErrorException
POSIX: time - get time.- Parameters:
tloc- an area where the return value is also stored.- Returns:
- the value of time.
- Throws:
NativeErrorException- if the return value of the native function indicates an error.
-
timer_create
public static final void timer_create(int clockid, Signal.Sigevent evp, Time.Timer_t timerid) throws NativeErrorException, NoSuchNativeMethodException- Throws:
NativeErrorException- if the return value of the native function indicates an error.NullPointerException- if((evp != null) && (evp.sigev_notify_attributes == null))otherwise we will get a SIGSEV.NoSuchNativeMethodException- if the method timer_create is not available natively.
-
timer_delete
public static final void timer_delete(Time.Timer_t timerid) throws NativeErrorException, NoSuchNativeMethodException
- Throws:
NativeErrorException- if the return value of the native function indicates an error.NoSuchNativeMethodException- if the method timer_delete is not available natively.
-
timer_getoverrun
public static final int timer_getoverrun(Time.Timer_t timerid) throws NativeErrorException, NoSuchNativeMethodException
- Throws:
NativeErrorException- if the return value of the native function indicates an error.NoSuchNativeMethodException- if the method timer_getoverrun is not available natively.
-
timer_gettime
public static final void timer_gettime(Time.Timer_t timerid, Time.Itimerspec value) throws NativeErrorException, NoSuchNativeMethodException
- Throws:
NativeErrorException- if the return value of the native function indicates an error.NoSuchNativeMethodException- if the method timer_gettime is not available natively.
-
timer_settime
public static final void timer_settime(Time.Timer_t timerid, int flags, Time.Itimerspec value, Time.Itimerspec ovalue) throws NativeErrorException, NoSuchNativeMethodException
- Throws:
NativeErrorException- if the return value of the native function indicates an error.NoSuchNativeMethodException
-
timezone
public static final long timezone() throws NoSuchNativeMethodException- Returns:
- the native value of timezone.
- Throws:
NoSuchNativeMethodException- if the method timezone is not available natively.
-
tzname
public static final String[] tzname()
- Returns:
- the native value of tzname.
-
tzset
public static final void tzset()
-
-