Package cern.nxcals.api.utils
Class TimeUtils
java.lang.Object
cern.nxcals.api.utils.TimeUtils
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumRepresents various time splits used in NXCALS. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final longstatic final longstatic final longstatic final long -
Method Summary
Modifier and TypeMethodDescriptionstatic InstantgetInstantFromNanos(long timeInNanos) Converts a long with the number of nanoseconds since epoch into itsInstantcounterpart.static InstantgetInstantFromString(@NonNull String timeString) static longgetMilisFromStringDate(@NonNull String timeString) static longgetNanosFromInstant(@NonNull Instant instantTime) Converts anInstantinto a long with the number of nanoseconds since epoch.static longgetNanosFromLocal(LocalDateTime localDateTime, ZoneId zoneId) static longConverts an current instant into a long with the number of nanoseconds since epoch.static longgetNanosFromString(@NonNull String timeString) Converts aStringinto a long with the number of nanoseconds since epoch.static StringgetStringDateFromInstant(@NonNull Instant instant) static StringgetStringDateFromNano(long timestampInNano) Deprecated.- Typo here, please use TimeUtils.getStringDateFromNanos()static StringgetStringDateFromNanos(long timestampInNanos) static StringgetStringFromInstant(@NonNull Instant instant) static StringgetStringFromNanos(long timestampInNanos) static longgetTimePartition(long timestamp, TimeUtils.TimeSplits max) static TimestampgetTimestampFromInstant(@NonNull Instant instant) static TimestampgetTimestampFromNanos(long timeInNanos) Converts a long with the number of nanoseconds since epoch into Timestamp.static TimestampgetTimestampFromString(@NonNull String timeString) static longtruncateToHours(long timestamp)
-
Field Details
-
CONVERT_EPOCH_NANOS_TO_SECONDS_VALUE
public static final long CONVERT_EPOCH_NANOS_TO_SECONDS_VALUE- See Also:
-
SECONDS_IN_DAY
public static final long SECONDS_IN_DAY- See Also:
-
NANOS_IN_DAY
public static final long NANOS_IN_DAY- See Also:
-
MILLIS_IN_HOUR
public static final long MILLIS_IN_HOUR
-
-
Method Details
-
truncateToHours
public static long truncateToHours(long timestamp) -
getTimePartition
-
getInstantFromNanos
Converts a long with the number of nanoseconds since epoch into itsInstantcounterpart.- Parameters:
timeInNanos- the number of seconds since epoch.- Returns:
- a new
Instant.
-
getTimestampFromNanos
Converts a long with the number of nanoseconds since epoch into Timestamp.- Parameters:
timeInNanos-- Returns:
- a new Timestamp
-
getNanosFromInstant
Converts anInstantinto a long with the number of nanoseconds since epoch.- Parameters:
instantTime- theInstantto be converter.- Returns:
- a long with the number of nanoseconds since epoch.
-
getNanosFromString
Converts aStringinto a long with the number of nanoseconds since epoch.- Parameters:
timeString- a string with the following format: yyyy-MM-dd HH:mm:ss.nnnnnnnnn- Returns:
- a long with the number of nanoseconds since epoch.
-
getNanosFromNow
public static long getNanosFromNow()Converts an current instant into a long with the number of nanoseconds since epoch.- Returns:
- a long with the number of nanoseconds since epoch.
-
getTimestampFromInstant
-
getTimestampFromString
-
getInstantFromString
- Parameters:
timeString- a string with the following format: yyyy-MM-dd HH:mm:ss.nnnnnnnnn- Returns:
- a new instance of
Instant.
-
getStringFromInstant
- Parameters:
instant- the instant to be converted.- Returns:
- a
Stringwith the following format: yyyy-MM-dd HH:mm:ss.nnnnnnnnn
-
getStringDateFromInstant
-
getStringDateFromNano
Deprecated.- Typo here, please use TimeUtils.getStringDateFromNanos() -
getStringDateFromNanos
-
getStringFromNanos
-
getMilisFromStringDate
-
getNanosFromLocal
-