Class TimeAgoParser
java.lang.Object
org.schabi.newpipe.extractor.localization.TimeAgoParser
A helper class that is meant to be used by services that need to parse durations such as
23 seconds and/or upload dates in the format 2 days ago or similar.-
Constructor Summary
ConstructorsConstructorDescriptionTimeAgoParser(PatternsHolder patternsHolder, LocalDateTime now) Creates a helper to parse upload dates in the format '2 days ago'. -
Method Summary
Modifier and TypeMethodDescriptionParses a textual date in the format '2 days ago' into a Calendar representation which is then wrapped in aDateWrapperobject.
-
Constructor Details
-
TimeAgoParser
Creates a helper to parse upload dates in the format '2 days ago'.Instantiate a new
TimeAgoParserevery time you extract a new batch of items.- Parameters:
patternsHolder- An object that holds the "time ago" patterns, special cases, and the language word separator.now- The current time
-
-
Method Details
-
parse
Parses a textual date in the format '2 days ago' into a Calendar representation which is then wrapped in aDateWrapperobject.Beginning with days ago, the date is considered as an approximation.
- Parameters:
textualDate- The original date as provided by the streaming service- Returns:
- The parsed time (can be approximated)
- Throws:
ParsingException- if the time unit could not be recognized
-