Package io.sentry
Class DateUtils
- java.lang.Object
-
- io.sentry.DateUtils
-
@Internal public final class DateUtils extends java.lang.ObjectUtilities to deal with dates
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static doubledateToSeconds(@NotNull java.util.Date date)ConvertDateto epoch time in seconds represented asDouble.static @NotNull java.util.DategetCurrentDateTime()Get the current Date (UTC)static @NotNull java.util.DategetDateTime(long millis)Get the Date from millis timestampstatic @NotNull java.util.DategetDateTime(@NotNull java.lang.String timestamp)Get the Date from UTC/ISO 8601 timestampstatic @NotNull java.util.DategetDateTimeWithMillisPrecision(@NotNull java.lang.String timestamp)Get the Date from millis timestampstatic @NotNull java.lang.StringgetTimestamp(@NotNull java.util.Date date)Get the UTC/ISO 8601 timestamp from Datestatic doublemillisToSeconds(double millis)Converts milliseconds to seconds.static doublenanosToMillis(double nanos)Converts nanoseconds to milliseconds
-
-
-
Method Detail
-
getCurrentDateTime
@NotNull public static @NotNull java.util.Date getCurrentDateTime()
Get the current Date (UTC)- Returns:
- the UTC Date
-
getDateTime
@NotNull public static @NotNull java.util.Date getDateTime(@NotNull @NotNull java.lang.String timestamp) throws java.lang.IllegalArgumentExceptionGet the Date from UTC/ISO 8601 timestamp- Parameters:
timestamp- UTC/ISO 8601 format eg 2000-12-31T23:59:58Z or 2000-12-31T23:59:58.123Z- Returns:
- the UTC Date
- Throws:
java.lang.IllegalArgumentException
-
getDateTimeWithMillisPrecision
@NotNull public static @NotNull java.util.Date getDateTimeWithMillisPrecision(@NotNull @NotNull java.lang.String timestamp) throws java.lang.IllegalArgumentExceptionGet the Date from millis timestamp- Parameters:
timestamp- millis eg 1581410911.988 (1581410911 seconds and 988 millis)- Returns:
- the UTC Date
- Throws:
java.lang.IllegalArgumentException
-
getTimestamp
@NotNull public static @NotNull java.lang.String getTimestamp(@NotNull @NotNull java.util.Date date)Get the UTC/ISO 8601 timestamp from Date- Parameters:
date- the UTC Date- Returns:
- the UTC/ISO 8601 timestamp
-
getDateTime
@NotNull public static @NotNull java.util.Date getDateTime(long millis)
Get the Date from millis timestamp- Parameters:
millis- the UTC millis from the epoch- Returns:
- the UTC Date
-
millisToSeconds
public static double millisToSeconds(double millis)
Converts milliseconds to seconds.- Parameters:
millis- - milliseconds- Returns:
- seconds
-
nanosToMillis
public static double nanosToMillis(double nanos)
Converts nanoseconds to milliseconds- Parameters:
nanos- - nanoseconds- Returns:
- milliseconds
-
dateToSeconds
public static double dateToSeconds(@NotNull @NotNull java.util.Date date)ConvertDateto epoch time in seconds represented asDouble.- Parameters:
date- - date- Returns:
- seconds
-
-