Class DateWrapper
java.lang.Object
org.schabi.newpipe.extractor.localization.DateWrapper
- All Implemented Interfaces:
Serializable
A wrapper class that provides a field to describe if the date/time is precise or just an
approximation.
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionDateWrapper(Instant instant) DateWrapper(Instant instant, boolean isApproximation) DateWrapper(LocalDateTime dateTime, boolean isApproximation) DateWrapper(OffsetDateTime offsetDateTime) DateWrapper(OffsetDateTime offsetDateTime, boolean isApproximation) -
Method Summary
Modifier and TypeMethodDescriptionstatic DateWrapperfromInstant(String date) Parses a date string that matches the ISO-8601Instantpattern, e.g.static DateWrapperfromOffsetDateTime(String date) Parses a date string that matches the ISO-8601OffsetDateTimepattern, e.g.getLocalDateTime(ZoneId zoneId) booleantoString()
-
Constructor Details
-
DateWrapper
-
DateWrapper
-
DateWrapper
-
DateWrapper
-
DateWrapper
-
-
Method Details
-
getInstant
- Returns:
- the wrapped
Instant
-
offsetDateTime
- Returns:
- the wrapped
Instantas anOffsetDateTimeset to UTC.
-
getLocalDateTime
- Returns:
- the wrapped
Instantas aLocalDateTimein the current time zone.
-
getLocalDateTime
- Returns:
- the wrapped
Instantas aLocalDateTimein the given time zone.
-
isApproximation
public boolean isApproximation()- Returns:
- if the date is considered is precise or just an approximation (e.g. service only returns an approximation like 2 weeks ago instead of a precise date).
-
toString
-
fromOffsetDateTime
Parses a date string that matches the ISO-8601OffsetDateTimepattern, e.g. "2011-12-03T10:15:30+01:00".- Parameters:
date- The date string- Returns:
- a non-approximate
DateWrapper, or null if the string is null - Throws:
ParsingException- if the string does not match the expected format
-
fromInstant
Parses a date string that matches the ISO-8601Instantpattern, e.g. "2011-12-03T10:15:30Z".- Parameters:
date- The date string- Returns:
- a non-approximate
DateWrapper, or null if the string is null - Throws:
ParsingException- if the string does not match the expected format
-