33import org .schabi .newpipe .extractor .exceptions .ParsingException ;
44
55import javax .annotation .Nonnull ;
6+ import javax .annotation .Nullable ;
67import java .io .Serializable ;
78import java .time .Instant ;
89import java .time .LocalDateTime ;
@@ -90,6 +91,15 @@ public String toString() {
9091 + '}' ;
9192 }
9293
94+ /**
95+ * Parses a date string that matches the ISO-8601 {@link OffsetDateTime} pattern, e.g.
96+ * "2011-12-03T10:15:30+01:00".
97+ *
98+ * @param date The date string
99+ * @return a non-approximate {@link DateWrapper}, or null if the string is null
100+ * @throws ParsingException if the string does not match the expected format
101+ */
102+ @ Nullable
93103 public static DateWrapper fromOffsetDateTime (final String date ) throws ParsingException {
94104 try {
95105 return date != null ? new DateWrapper (OffsetDateTime .parse (date )) : null ;
@@ -98,6 +108,15 @@ public static DateWrapper fromOffsetDateTime(final String date) throws ParsingEx
98108 }
99109 }
100110
111+ /**
112+ * Parses a date string that matches the ISO-8601 {@link Instant} pattern, e.g.
113+ * "2011-12-03T10:15:30Z".
114+ *
115+ * @param date The date string
116+ * @return a non-approximate {@link DateWrapper}, or null if the string is null
117+ * @throws ParsingException if the string does not match the expected format
118+ */
119+ @ Nullable
101120 public static DateWrapper fromInstant (final String date ) throws ParsingException {
102121 try {
103122 return date != null ? new DateWrapper (Instant .parse (date )) : null ;
0 commit comments