java.lang.Object
com.apptasticsoftware.rssreader.DateTime
- All Implemented Interfaces:
DateTimeParser
Class for converting date time strings.
This class is only used when sorting or when calling getters that returns ZonedDateTime.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionConverts a timestamp in String format to a ZonedDateTimestatic Comparator
<Item> Deprecated, for removal: This API element is subject to removal in a future version.This method be removed in a future version.toEpochMilli
(String dateTime) Convert date time string to time in millisecondsConverts timestamp string to InstanttoLocalDateTime
(String dateTime) Converts date time string to LocalDateTime object.toZonedDateTime
(String dateTime) Converts date time string to ZonedDateTime object.
-
Constructor Details
-
DateTime
public DateTime()Creates DateTime object for converting timestamps. Using default timezone UTC if no timezone information if found in timestamp. -
DateTime
Creates DateTime object for converting timestamps.- Parameters:
defaultZone
- time zone to use if no timezone information if found in timestamp
-
-
Method Details
-
toLocalDateTime
Converts date time string to LocalDateTime object. Note any time zone information in date time string is ignored.- Parameters:
dateTime
- date time string- Returns:
- local date time object
-
toZonedDateTime
Converts date time string to ZonedDateTime object. Use if time date string contains time zone information.- Parameters:
dateTime
- date time string- Returns:
- zoned date time object
-
toEpochMilli
Convert date time string to time in milliseconds- Parameters:
dateTime
- date time string- Returns:
- time in milliseconds
-
toInstant
Converts timestamp string to Instant- Specified by:
toInstant
in interfaceDateTimeParser
- Parameters:
dateTime
- timestamp- Returns:
- instant
-
pubDateComparator
Deprecated, for removal: This API element is subject to removal in a future version.This method be removed in a future version.Use
ItemComparator.oldestItemFirst()
instead.Comparator comparing publication date of Item class. Sorted in ascending order (oldest first)- Returns:
- comparator
-
parse
Converts a timestamp in String format to a ZonedDateTime- Specified by:
parse
in interfaceDateTimeParser
- Parameters:
timestamp
- timestamp- Returns:
- ZonedDateTime
-