Module org.elasticsearch.xcore
Interface TimestampConverter
- All Known Implementing Classes:
DateTimeFormatterTimestampConverter
public interface TimestampConverter
A converter that enables conversions of textual timestamps to epoch seconds
or milliseconds according to a given pattern.
-
Method Summary
Modifier and TypeMethodDescriptionlongtoEpochMillis(String timestamp) Converts the a textual timestamp into an epoch in millisecondslongtoEpochSeconds(String timestamp) Converts the a textual timestamp into an epoch in seconds
-
Method Details
-
toEpochSeconds
Converts the a textual timestamp into an epoch in seconds- Parameters:
timestamp- the timestamp to convert, not null. The timestamp is expected to be formatted according to the pattern of the formatter. In addition, the pattern is assumed to contain both date and time information.- Returns:
- the epoch in seconds for the given timestamp
- Throws:
DateTimeParseException- if unable to parse the given timestamp
-
toEpochMillis
Converts the a textual timestamp into an epoch in milliseconds- Parameters:
timestamp- the timestamp to convert, not null. The timestamp is expected to be formatted according to the pattern of the formatter. In addition, the pattern is assumed to contain both date and time information.- Returns:
- the epoch in milliseconds for the given timestamp
- Throws:
DateTimeParseException- if unable to parse the given timestamp
-